简体   繁体   中英

Database DB2 Triggers

I am writing some triggers for our DB2 database tables, but I don't have rights to test them...I know...but just a quick question here. Does the NEW and OLD keywords give you the whole row that was updated or just the certain fields that were updated? For example, if I have a table where 1 row just got updated and, only 2 fields in that row got updated/changed do I still get the whole row to work with when I use the NEW keyword? That was my understanding, that even though other fields got updated and others didn't, that I could still refer to any field/value of the entire row using the NEW keyword.

Some illustration here:

Table row:

|first_name | last_name | age | gender | state        | city        |

|"Tom"      | "Sawyer"  | 80  | "male" | "California" | "Sacramento"|

Update to same table row:

|first_name | last_name | age | gender | state        | city        |

|"John"     | "Doe"     | 80  | "male" | "California" | "Sacramento"|

After the update do I still get the age, gender, state, and city field values using the NEW keyword? As in NEW.age = 80, NEW.state = "California" etc.

or does it only give me the first and last name because they were the only fields to change?

是的,您可以访问具有NEW相关性的行中的所有列。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM