を使用してプロシージャを作成しました。execute immediate
デバッグしexecute immediate
てこのプロシージャにステップオーバーすると、次のメッセージが表示されます。
コードで Oracle 例外が発生しました。コードに例外ハンドラーが含まれている場合は、ハンドラーのステップ実行を続行できます。そうしないと、エラー メッセージが表示され、次のステップで実行が終了します。
次に、クエリを取り出します。即時実行のクエリは次のとおりです。
update mstarea
set '||v_temp_position||' = :pid
where areacode = :pnewarea1
connect by prior areacode = areaparent
start with areacode in (:pnewarea1, :pnewarea2);
そのクエリを実行/コンパイルしようとすると、次のようなエラーが発生します。
ORA-00933: SQLコマンドが正しく終了していません
connect by prior
でサポートされていupdate
ますか?
これが私の手順で、 にupdate mstarea
なった時のエラーは以下execute immediate
です。
CREATE OR REPLACE procedure PROC1(pid in varchar2, pposition in varchar2, pnewarea1 in varchar2, pnewarea2 in varchar2)
is
v_error_message varchar2(255);
v_temp_position varchar2(25 byte);
v_sql_statement varchar2(255);
n_count_role number;
cursor cuser is
select userid from master.mstuser where id = pid;
begin
for cdata in cuser
loop
begin
select count(role) into n_count_role from mstmapping where role = pposition;
if n_count_role > 0 then
begin
..........
if pnewarea1 = 'ALL' then
..........
else
..........
------------------- update mstarea -------------------
if pposition in ('A', 'B') then
select 'AB' into v_temp_position from dual;
else
select pposition into v_temp_position from dual;
end if;
v_sql_statement := 'update mstarea set '||v_temp_position||' = :pid where areacode = :pnewarea1 connect by prior areacode = areaparent start with areacode in (:pnewarea1, :pnewarea2)';
execute immediate v_sql_statement using pid, pnewarea1, pnewarea1, pnewarea2; -- advice from @Rene
------------------------------------------------------
..........
end;
end if;
end;
end if;
exception
when others then
..........
rollback;
end;
commit;
exit when cuser%notfound;
end loop;
end;
これを修正するにはどうすればよいですか?