All Forums Database
Tnewbee 215 posts Joined 05/10
15 Jun 2010
Capture the data while updating a table

Hi all!

I have a sequence of update queries on a very huge table TableA. Now when it updates the table I want to capture all the primary key of the records getting updated. This primary key will then be used to join with TAble B. Can I achieve this in the Update statement itself? I read we have ON UPDATE clause in SQL which can do this. Do we have a similar option in Teradata?

I can create a temp table with the primary key instead of updating the table directly and then use this temp table to update TableA as well as join with TableB. But as I said earlier there are multiple such Update statements. SO I will have to drop and create this table multiple times.
Also, the Update statement updates the Status. And the second Update statement uses this status in TABLEA to update it. So I have to make sure I update the tableA as well as capture the primary key. I cannot keep inserting records in the temp table and then in the end Update the TableA.
Any help is appreciated!

Tnewbee 215 posts Joined 05/10
15 Jun 2010

Anyobody with any suggestions?
BTW, we are not allowed to use a trigger or stored procedure.

Adeel Chaudhry 773 posts Joined 04/08
16 Jun 2010


Triggers would be your best bet .... but as you mentioned you are not allowed to use them .... can you share some UPDATE statements to clear the overall picture?



-- If you are stuck at something .... consider it an opportunity to think anew.

Tnewbee 215 posts Joined 05/10
16 Jun 2010

Thanks for ur reply!
I have added a flag which I will be setting whenever a record gets updated. In this way after all updates, I can use the flag to find the updated records.

You must sign in to leave a comment.