Columns Affected by UPDATE STATEMENT

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • aaa1234
    New Member
    • Feb 2008
    • 1

    Columns Affected by UPDATE STATEMENT

    HI,

    I am writing a trigger to update table b, depending on updates on table a.
    table a and b has 300 columns. I want to update only those columns which are changed by update statement like, lets say col is a column in table a
    my trigger body will be
    UPDATE TRIGGER ON A
    OLD AS O
    NEW AS N
    if ( O.col <> N.co) then
    update b set col = some value

    end if


    since i have so many columns to check, performance is very low. it takes more than 20 seconds to complete the process. Please help me out to find out a way to identify only those columns which have been updated. Is there any way? If so please let me know.


    Thanks
    Guru
  • sakumar9
    Recognized Expert New Member
    • Jan 2008
    • 127

    #2
    According to your example, what I interpret is for every meaningful change in table A (old and new values are different), you want to set something in table B.

    Can you give me some idea behind this scenario on what exactly you want to do?


    Regards
    -- Sanjay

    Comment

    • sakumar9
      Recognized Expert New Member
      • Jan 2008
      • 127

      #3
      I think I got you, you want to have similar change in table B as table A (the column that is changed in A, you want similar column change in table B), so you want to compare the values of each column before and after the row is inserted to find out which column is actually updated.

      Is my understanding correct??

      Well in that case, I do not have idea about alternatives. But I would request you to please DO let me know if you get the solution.


      Regards
      -- Sanjay

      Comment

      Working...