当前位置: 代码迷 >> Oracle管理 >> jdbc更新顺利返回某列的值
  详细解决方案

jdbc更新顺利返回某列的值

热度:20   发布时间:2016-04-24 05:00:57.0
jdbc更新成功返回某列的值
我知道更新成功之后可以返回主键的值,现在有没有方法可以返回指定更新记录中的某一列的值?

  如果没有的话,又要一个sql语句进行查询,好麻烦。

------解决方案--------------------
用returning子句就可以做到。
------解决方案--------------------
returning子句。
------解决方案--------------------
SQL code
SQL> select * from a;A                    B                    C-------------------- -------------------- ----------1                    1b                   1c2                    1                    2c3                    3                    3cSQL> 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  /2cPL/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;
  相关解决方案