当前位置: 动力学知识库 > 问答 > 编程问答 >

sql - How to return columns before update using returning?

问题描述:

Hey in PL/SQL consider this query :

update cards s set s.column1= null, s.column2= null

where s.column3= in_column3

returning s.column1,s.column2

into v_column1,v_column2;

Problem is this puts the new records in the variables, which are null but I'm intrested in the values before the update.

Is there any way I can achieve this using RETURNING clause?

网友答案:

No, returning will give you the column values that result after the update. So better select the column values before you update.

select s.column1,
       s.column2
into v_column1,v_column2
from cards s
where s.column3= in_column3;
网友答案:

You can write a before update trigger on this table which will store the previous values in a specific table in a specific condition. Or you can prevent the insertion if the new values being inserted are null.

分享给朋友:
您可能感兴趣的文章:
随机阅读: