日期:2014-05-17  浏览次数:20678 次

jdbc更新成功返回某列的值
   我知道更新成功之后可以返回主键的值,现在有没有方法可以返回指定更新记录中的某一列的值?

   如果没有的话,又要一个sql语句进行查询,好麻烦。
------解决方案--------------------
用returning子句就可以做到。
------解决方案--------------------
returning子句。
------解决方案--------------------
SQL> select * from a;

A                    B                    C
-------------------- -------------------- ----------
1                    1b                   1c
2                    1                    2c
3                    3                    3c

SQL> variable rtn varchar2(20);
SQL> begin
  2  update a set b = '2b' WHERE A=2 returning c into :rtn;
  3  dbms_output.put_line(:rtn);
  4  end;
  5  /
2c

PL/SQL procedure successfully completed.


------解决方案--------------------
PL/SQL Developer

declare
  rtn number;
begin 
update student set age=276 where id=11 returning age into rtn;
dbms_output.put_line(rtn);
end;