update 失败的返回码?

愚痴鱼 2009-07-30 10:34:29
在Oracle中执行一条update语句,如果符合where条件的数据不存在,会有一个特定的错误码返回吗?
...全文
116 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
inthirties 2009-07-30
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 inthirties 的回复:]
如果是在plsql块里

可以用sql%rowcount或者sql%notfound来判断

比如
SQL> begin
update t1 set 1 = 1; === 这里不对 应该是 update t1 set col1=col1 where 1=1;
dbms_output.put_line(sql%rowcount);
update t1 set 1 <> 1; === 这里不对 应该是 update t1 set col1=col1 where 1<>1;
if sql%notfound then
dbms_output.put_line('Not found');
end if
end;
/
[/Quote]

有错误。
inthirties 2009-07-30
  • 打赏
  • 举报
回复
如果是在plsql块里

可以用sql%rowcount或者sql%notfound来判断

比如
SQL> begin
update t1 set 1 = 1;
dbms_output.put_line(sql%rowcount);
update t1 set 1 <> 1;
if sql%notfound then
dbms_output.put_line('Not found');
end if
end;
/
csuxp2008 2009-07-30
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 zxf_feng 的回复:]
NOT_DATA_FOUND是不是这个,试一下
[/Quote]

no_data_found
csuxp2008 2009-07-30
  • 打赏
  • 举报
回复
显示 返回0行
阿三 2009-07-30
  • 打赏
  • 举报
回复
NOT_DATA_FOUND是不是这个,试一下
inthirties 2009-07-30
  • 打赏
  • 举报
回复
没有,没有记录update而已。

17,377

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 基础和管理
社区管理员
  • 基础和管理社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧