Create my First trigger Help

  • I created this one also in Newbies to see which option can help me as quickly as possible. I have a dead line today and have not have any luck making this to work, HELP PLEASE!!!! 

    EMERGENCY FOR TODAY!! THANK YOU EMERGENCY FOR TODAY

    Good morning. I need to create a trigger (my first one!) but so far I have no luck making it to work.

    What I need is the following:

    I have a table (table 1) with a few fields the essential ones are: Record_Number (assigned by an outside source, let's say Parent company), accountnumber1, accountnumber2, record_id_Search1 and record_Search (last six digits of the account numbers). All fields are char (19), but the original values have 7 characters, and 12, but the length was assigned as 19 for future inserts

    A second table (table 2) has the same fields plus some others.

    The when update or insert records the trigger must complete these tasks:

    1. update record_is_search1 and record_id_search2 (default value 0) with the last six digits of the accountnumber1 and/or accountnumber2

    2. When update or insert accountnumber1 and/or accountnumber2 in table 1, update or insert those values in table 2 with the account number+8 digits assigned by us (date formated as 20041114)

    3. Last Update accountnumber1 and/or accountnumber2 in table 1 with the same values inserted or updated in table 2.

    I am able to do this one by one, but not with a trigger. Reason??? Not knowing how. PLEASE HELP!!

  • You can use EM to create the trigger.  Within the trigger code, use the same SQL statement that you would use if doing it manually, but do you select from either INSERTED,  or UPDATED.

    They are both recordsets based on the currrently inserted or updated recordsets.  

    If you can do it one by one.. the trigger should be easy enough to write.

    Hope this helps.

  • Thank you for the iput in this matter. I read a little more, test a few things and it seems to be working as I needed. Please consider this item as closed. Thank you

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply