Results 1 to 2 of 2

Thread: SQL, Compare then update a field after insertion

  1. #1
    Banned
    Join Date
    Dec 2007
    Answers
    2

    SQL, Compare then update a field after insertion

    I have two tables in SQL: tbl_names, and tbl_insert.
    the field named: tbl_names.field_dictionary contains names.
    the tbl_insert contains many fields and one of them is called tbl_insert.field_keywords and another 2 fields called tbl_insert.field_title and tbl_insert.field_details.
    now my question is the following:
    I need a stored procedure code to tell sql every time I insert a record in tbl_insert i want the sql to compare tbl_names.field_dictionary against tbl_insert.field_title and tbl_insert.field_details ; if those two fields contains the keywords listed in tbl_names.field_dictionary; i need to insert/update the field named: tbl_insert.field_keywords by inserting only the founded keywords inside the tbl_names.field_dictionary into the tbl_insert.field_keywords without repeating the words found inside the field.
    I hope someone can help me in providing me with this code, take it as a challange.

    Last edited by talalmanaa; 12-07-2007 at 11:38 AM. Reason: type error

  2. #2
    Junior Member
    Join Date
    Jan 2008
    Answers
    2

    Re: SQL, Compare then update a field after insertion

    You can compare by using before insert trigger, by putting your stored procedure code inside the trigger on table tbl_insert. Even you can use after insert trigger, check the content of inserted value with field_dictionary of the tbl_names table, if it is matching, commit the changes else rollback.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact