[英]How to call a function in select statement which is having OUT parameter in it?
If i have a function with OUT parameters then how can we call that function in select statement. 如果我有一个带有OUT参数的函数,那么我们如何在select语句中调用该函数。
my function is as below 我的功能如下
CREATE OR REPLACE FUNCTION fun_1 (p_in IN VARCHAR2, p_out OUT NUMBER)
RETURN number
AS
BEGIN
SELECT SAL INTO p_out FROM emp WHERE ename=P_in;
RETURN p_out;
END;
i want to call that function through select statement as below. 我想通过如下的select语句调用该函数。
select fun_1('KING', lv_var) from dual;
is it possible. 可能吗。 ?
?
Is this possible? 这可能吗? NO
没有
Because, with normal variable,it will give complile time error saying - 因为,使用正常变量,它将给出复杂的时间错误,说-
"LV_VAR": invalid identifier
Then I tried that using bind variables (:lv_var)
. 然后我尝试使用绑定变量
(:lv_var)
。 It gave run time error(after setting the bind variable). 它给运行时错误(设置绑定变量后)。 The reason is -
原因是 -
PL/SQL functions referenced by SQL statements must not contain the OUT parameter.
SQL语句引用的PL / SQL函数不得包含OUT参数。
ORA-06572: Function FUN_1 has out arguments
06572. 00000 - "Function %s has out arguments"
*Cause: A SQL statement references either a packaged, or a stand-alone,
PL/SQL function that contains an OUT parameter in its argument
list. PL/SQL functions referenced by SQL statements must not
contain the OUT parameter.
*Action: Recreate the PL/SQL function without the OUT parameter in the
argument list.
Hope this helps. 希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.