我有一个带参数的存储过程,参数必须是默认的nothing,但我想做一个if parameter = name_procedure exec procedure else nothing的存储过程。

问题描述 投票:-1回答:1
create or replace procedure1(l_nothing varchar2)
as
begin
if l_nothing := procedure_2 then
exec procedure_2(2);
else l_nothing := NULL
dbms.output_put_line(l_nothing);
end if;
end;
/

create or replace procedure2(l_id in varchar2)
return NUMBER is l_name NUMBER(9);
begin
select name into l_name from test where  l_id =id;
return  l_name;
end;
/

能否让o存储过程用if语句执行另一个存储过程?

sql oracle plsql plsqldeveloper plsql-psp
1个回答
2
投票
create or replace procedure1(l_nothing varchar2)
as
begin
    if lower(l_nothing) = 'procedure2' then
      procedure2(2);
    else 
      dbms.output_put_line(l_nothing);
    end if;
end;

过程没有返回任何值......所以,你需要把过程2改为函数或者在过程2中创建一个输出参数。

© www.soinside.com 2019 - 2024. All rights reserved.