Oracle SQL - can I return the "before" state of a column value -


assume following row in mytable:

id     =  1 letter = 'a' 

in oracle, 1 can following:

update mytable set   letter = 'b' id   = 1 returning letter  myvariable; 

and myvariable hold value 'b'.

what looking way of returning "before" value of letter

ie. replace previous update with:

update mytable set   letter = 'b' id   = 1 returning letter "before update" myvariable; 

and myvariable should hold value 'a';

i understand t-sql can achieve via output clause.

is there oracle equivalent way of achieving don't have first "select" before value?

update   (    select t.*, (select letter dual) old_letter      mytable t     id=1   )    set letter = 'b' returning old_letter myvariable; 

tested on oracle 11.2


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -