17,089
社区成员
发帖
与我相关
我的任务
分享
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;