动态存储过程,不知道哪儿错了

yundeweilai 2014-09-17 01:00:12
create or replace procedure merge_rio
is
v_itm varchar2(100);
v_sql varchar2(500);
v_sql1 varchar2(500);
i number;
begin
for i in 1..9 loop
v_itm:='C000'||i
v_sql:='merge into tmp_whq_rio_data_test a using (select * from tmp_whq_rio where itemcode='''||v_itm||''') b on (a.storecode=b.storecode) when matched then update set a.'||v_itm||'1=b.有无铺货,a.'||v_itm||'2=b.单价 ';
execute immediate v_sql;
end loop;
i:=10;
for i in 10..25 loop
v_itm:='C00'||i
v_sql1:='merge into tmp_whq_rio_data_test a using (select * from tmp_whq_rio where itemcode='''||v_itm||''') b on (a.storecode=b.storecode) when matched then update set a.'||v_itm||'1=b.有无铺货, a.'||v_itm||'2=b.单价 ';
execute immediate v_sql1;
end loop;
exception
when no_data_found then --直接抛出异常
dbms_output.put_line('不存在该工资值的雇员');
when too_many_rows then
dbms_output.put_line('存在多个雇员具有该工资');
when others then
rollback;
dbms_output.put_line('异常回滚退出');
end merge_rio;
...全文
93 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
yundeweilai 2014-09-17
  • 打赏
  • 举报
回复
引用 1 楼 bw555 的回复:
错误信息提供下
对,刚发布,我就找到原因了,谢谢
bw555 2014-09-17
  • 打赏
  • 举报
回复
貌似就丢了2个分号 两个给 v_itm赋值的语句的最后
procedure merge_rio
is
v_itm varchar2(100);
v_sql varchar2(500);
v_sql1 varchar2(500);
i number;
begin
        for i in 1..9 loop
             v_itm:='C000'||i;
             v_sql:='merge into tmp_whq_rio_data_test a using (select * from tmp_whq_rio where itemcode='''||v_itm||''') b on (a.storecode=b.storecode) when matched then update set a.'||v_itm||'1=b.有无铺货,a.'||v_itm||'2=b.单价 ';
                         execute immediate v_sql;
       end loop;
             i:=10;
             for i in 10..25 loop
                     v_itm:='C00'||i;
                   v_sql1:='merge into tmp_whq_rio_data_test a using (select * from tmp_whq_rio where itemcode='''||v_itm||''') b on (a.storecode=b.storecode) when matched then update set a.'||v_itm||'1=b.有无铺货, a.'||v_itm||'2=b.单价 ';
             execute immediate v_sql1;
       end loop;
       exception
   when no_data_found then  --直接抛出异常
     dbms_output.put_line('不存在该工资值的雇员');
   when too_many_rows then
     dbms_output.put_line('存在多个雇员具有该工资');
   when others then
     rollback;
     dbms_output.put_line('异常回滚退出');
end merge_rio;
bw555 2014-09-17
  • 打赏
  • 举报
回复
错误信息提供下

17,089

社区成员

发帖
与我相关
我的任务
社区描述
Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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