oracle 报错pls 00405,oracle - 检查是否存在PLS-00405:在此上下文中不允许子查询 - 堆栈内存溢出...
使用正確的語法,將如下所示:
create or replace procedure daily_rpt
( v_start in date
, v_end in date )
as
begin
for r in (
select ao_out_no, 0 as exists_check
from tablea
)
loop
select count(*) into exists_check
from tablea
where out_no = r.ao_out_no
and rownum = 1;
if r.exists_check > 0 then
--DO NOTHING
else
insert into tableb (out_no) values (r.ao_out_no);
end if;
end loop;
end;
但是,查詢所有行然后對每行進行一次額外的查找來確定是否要使用它是低效率的,因為SQL可以為您做這種事情。 因此版本2可能類似于:
create or replace procedure daily_rpt
( v_start in date
, v_end in date )
as
begin
for r in (
select ao_out_no
from tablea
where not exists
( select count(*)
from tablea
where out_no = r.ao_out_no
and rownum = 1 )
)
loop
insert into tableb (out_no) values (r.ao_out_no);
end loop;
end;
在這一點上,您可以將整個循環替換為insert ... where not exists (...)語句。
總結
以上是生活随笔為你收集整理的oracle 报错pls 00405,oracle - 检查是否存在PLS-00405:在此上下文中不允许子查询 - 堆栈内存溢出...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: oracle19c怎么创建Scott,O
- 下一篇: linux驱动读取文件失败怎么办,lin