DBAsupport.com Forums - Powered by vBulletin
Results 1 to 4 of 4

Thread: Tricky Trigger

  1. #1
    Join Date
    Aug 2000
    Location
    Shanghai
    Posts
    433

    Tricky Trigger

    I have a transaction table which is increasing 300K records every month .

    let's say the PK of this table is C1+C2+C3

    And now I want to write a trigger to extract distinct C1+C2
    into another table .

    My problem is as the number of C1+C2 is much less than the number of C1+C2+C3 , ( 1%) and the trigger is fired by row level
    so in the trigger I have to check whether C1+C2 has been already inserted into the table , that is pain .

    T1: T2:
    C1 C2 C3A ---> Insert C1 C2
    C1 C2 C3B ---> Check Existence , NO insertion
    C1 C2 C3C ---> Check Existence , NO insertion
    C1 C2 C3D ---> Check Existence , NO insertion

    Any good solution to make it simple ?
    1. www.dbasupport.com
    2. www.dbforums.com
    3. www.itpub.net
    4. www.csdn.net
    5. www.umlchina.com
    6. www.tek-tips.com
    7. www.cnforyou.com
    8. fm365.federal.com.cn
    9. www.programmersheaven.com
    10.http://msdn.microsoft.com/library/default.asp
    ligang1000@hotmail.com

  2. #2
    Join Date
    Nov 2000
    Location
    greenwich.ct.us
    Posts
    9,092
    sure, always insert c1 + c2 and catch the DUP_VAL_ON_INDEX in a EXCEPTION block and then ignore it.
    Jeff Hunter

  3. #3
    Join Date
    Aug 2000
    Location
    Shanghai
    Posts
    433
    how is the performance consideration in this case?
    1. www.dbasupport.com
    2. www.dbforums.com
    3. www.itpub.net
    4. www.csdn.net
    5. www.umlchina.com
    6. www.tek-tips.com
    7. www.cnforyou.com
    8. fm365.federal.com.cn
    9. www.programmersheaven.com
    10.http://msdn.microsoft.com/library/default.asp
    ligang1000@hotmail.com

  4. #4
    Join Date
    Nov 2000
    Location
    greenwich.ct.us
    Posts
    9,092
    You have a business requirement, right?
    Jeff Hunter

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width