当我这样做时:
select sum(m.mot)
from rmtq mq
join rmo m on mq.id = m.id
where mq.another = 138;
返回值= 2,这是正确的。但是当我把这段代码放在一个函数中时:
create or replace function get(another in number) return number
is ret number := 0;
begin
select sum(m.mot)
into ret
from rmtq mq
join rmo m on mq.id = m.id
where mq.another = another
return(ret);
end;
我打来电话:
exec dbms_output.put_line(get(138));
返回值= 39,这是不正确的。这是什么39?
答案 0 :(得分:0)
评论是有问题的;为了避免浪费时间,你必须正确地写出参数的名称,例如:
create or replace function get(p_another in number) return number
is ret number := 0;
begin
select sum(m.mot)
into ret
from rmtq mq
join rmo m on mq.id = m.id
where mq.another = p_another
return(ret);
end;