您的位置:首页 > 数据库 > Oracle

oracle select into 的时候提示未找到数据

2016-07-07 15:50 141 查看
declare version varchar2(50);
begin
select version into version_id from 表a where 字段 = '1';

--在select into 后面添加exception 错误处理机制
exception
when no_data_found then
version:= 'hhh ';

--以上是处理select into 的时候提示未找到数据的处理方法
if version is null or version ='' then
INSERT INTO 表a (字段)
select NVL(max(VERSION),0)+1 from 表b ;
update 表3 set VERSION = (select NVL(max(VERSION),0) from 表a where 字段 = '1' )
where 字段 = '1';
commit;
end if;
end;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: