简体   繁体   English

如何在其中具有OUT参数的select语句中调用函数?

[英]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.

相关问题 如何将select语句的IN子句中的参数作为具有多个值的参数传递? - How to pass arguments in IN clause of select statement as parameter having multiple values? 如何在SELECT语句中以列名作为参数调用用户定义的函数? - How to call User-defined function in SELECT statement with Column Name as parameter? 如何调用以SYS_REFCURSOR作为OUT参数的Oracle函数 - How to call Oracle function which has SYS_REFCURSOR as OUT Parameter 如何使用Java调用Oracle数据库中IN和OUT参数的存储函数 - how to call stored function of IN and OUT parameter in Oracle Database using Java 如何创建一个根据选择语句结果返回布尔值的函数 - How to create a function which return a boolean depending on a select statement result 如何编写SELECT语句,其中条件是函数的结果 - How can I write a SELECT statement in which the condition is the result of a function 如何查询参数是否为null(当一个或多个参数为空时,具有多个参数和select语句会发生变化) - How to query if parameter is null ( having multiples parameters and select statement changes when one or multiples parameters are null) 如何在 select 语句中调用表值 function? - How to call table valued function inside select Statement? 在SQL中使用select语句创建函数 - Creating a function out of a select statement in SQL 如何在 SELECT 语句中使用 HAVING 子句? - How to use HAVING clause in the SELECT statement?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM