我正在尝试这种方法,但是我肯定错过了很多
declare
my_id table.ISR_ID%type;
begin
select NVL(MAX(table.ISR_ID)+1,1) into isr_id
from table;
select my_pkg.getFunction(InputToFunction=> isr_id); -- from ?
end;
答案 0 :(得分:1)
如果您声明了MY_ID变量,则应该选择其中,而不是ISR_ID(从未声明)。
此外,您应该将函数的结果返回到 something (可能是另一个变量?)中。我已将其声明为FUN_RES-请参阅PL / SQL匿名块中的注释。
说您缺少很多东西并没有多大帮助;您应该指定遇到的错误。无论如何:尝试这样的代码,说出它是否有效,如果没有,请说出为什么(可能的错误等)。
declare
my_id table.ISR_ID%type;
fun_res number; --> function result should be returned into this variable.
-- I don't know what it returns, so I set it to be a NUMBER.
-- Change it, if necessary.
begin
select NVL(MAX(table.ISR_ID) + 1, 1)
into my_id
from table;
fun_res := my_pkg.getFunction(my_id);
end;
[编辑]
如果必须为表中的每个ISR_ID选择函数的值,那么就不需要PL / SQL,但是
select isr_id,
my_pkg.getfunction(isr_id) fun_res
from table;
如果要使用PL / SQL,请循环执行,例如:
begin
for cur_r in (select isr_id from table) loop
dbms_output.put_line(cur_r.isr_id ||', result = ' || my_pkg.getfunction(cur_r.isr_id));
end loop;
end;
/