在pl/sql函数中选择clausule返回错误的值 [英] Select clausule inside pl/sql function return wrong value
本文介绍了在pl/sql函数中选择clausule返回错误的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我这样做时:
select sum(m.mot)
from rmtq mq
join rmo m on mq.id = m.id
where mq.another = 138;
返回值= 2,这是正确的.但是,当我将这段代码放在一个函数中时:
return value = 2, which is correct. But when I put this code inside a function:
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?
return value = 39, which is incorrect. What is that 39?
推荐答案
评论正确无误;为了避免任何人浪费时间,您必须正确输入参数名称,例如:
The comments were right to question; lest anyone waste time on this you have to write the names of the parameters correctly, for example:
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;
这篇关于在pl/sql函数中选择clausule返回错误的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文