Ask Your Question
0

Is it possible to create a DB2 trigger that will update only one column of the updated row in the same table after an update?

asked 2021-10-16 11:00:00 +0000

pufferfish gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2021-11-28 00:00:00 +0000

lakamha gravatar image

Yes, it is possible to create a DB2 trigger that will update only one column of the updated row in the same table after an update. Here's an example of the trigger:

CREATE TRIGGER update_column
AFTER UPDATE ON your_table
REFERENCING NEW AS n
FOR EACH ROW
BEGIN ATOMIC
    UPDATE your_table
    SET column_name = n.column_name
    WHERE primary_key = n.primary_key;
END

In this example, replace your_table with the name of your table and column_name with the name of the column you want to update. The trigger will only update the specified column for the row that was updated.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2021-10-16 11:00:00 +0000

Seen: 9 times

Last updated: Nov 28 '21