Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

UPDATE with RETURNING INTO old, not new values??

SebaVastaNov 1 2024
We have a 11g R2 EE.  Is it possible to UPDATE a table row (3 fields) but also RETURN the old values (not the newly updated values, which I am suppling), i.e. the 3 values BEFORE the my update, in one UPDATE statement, like 
  UPDATE tab1 
  SET   f1 = 1, f2 = 2, f3 = 3 
  WHERE clause1 
  RETURNING f1, f2, f3 INTO v_f1_old, v_f2_old, v_f3_old;
Suppose before my above update the values for the 3 fields are f1 = 11, f2 = 22, f3 = 33, I want my variables to have these 3 values.

Otherwise I need a SELECT to get current values and then UPDATE the 3 fields, but I want to reduce the calls.
This post has been answered by Anthony Harper on Nov 2 2024
Jump to Answer
Comments
Post Details
Added on Nov 1 2024
5 comments
1,152 views