oracle 报错pls 00405,oracle - 检查是否存在PLS-00405:在此上下文中不允许子查询 - 堆栈内存溢出...
使用正確的語(yǔ)法,將如下所示:
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;
但是,查詢(xún)所有行然后對(duì)每行進(jìn)行一次額外的查找來(lái)確定是否要使用它是低效率的,因?yàn)镾QL可以為您做這種事情。 因此版本2可能類(lèi)似于:
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;
在這一點(diǎn)上,您可以將整個(gè)循環(huán)替換為insert ... where not exists (...)語(yǔ)句。
總結(jié)
以上是生活随笔為你收集整理的oracle 报错pls 00405,oracle - 检查是否存在PLS-00405:在此上下文中不允许子查询 - 堆栈内存溢出...的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: oracle19c怎么创建Scott,O
- 下一篇: linux驱动读取文件失败怎么办,lin