批量执⾏多条sql语句
在程序中执⾏的原sql语句如下:
update TB_VG set seq = 1, vessel_id = 'Jin14', vessel_type = 'TRACK' where batch_number = '20837' and train_id = '0233086';
update TB_VG set seq = 2, vessel_id = 'Jin14', vessel_type = 'TRACK' where batch_number = '20992' and train_id = '0233110';
这个时候会报错:
【ORA-00911: ⽆效字符】
修改sql语句如下:
begin
update TB_VG set seq = 1, vessel_id = 'Jin14', vessel_type = 'TRACK' where batch_number = '20837' and train_id = '0233086';
update TB_VG set seq = 2, vessel_id = 'Jin14', vessel_type = 'TRACK' where batch_number = '20992' and train_id = '0233110';
end;
如果不采⽤这种⽅式,可能的异常有:
ORA-00933: SQL 命令未正确结束(如果sql没有以分号结尾)
批量更新sql语句ORA-00911: ⽆效字符(如果未加begin 和 end)
ORA-06550: 第x⾏, 第xxx列: PLS-00103: 出现符号 "end-of-file"在需要下列之⼀时:......(如果end后⾯没有;分号)
ORA-06550: 第x⾏, 第xxx列: PLS-00103: 出现符号 ""在需要下列之⼀时:......(语句之间有换⾏符)

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。