【发布时间】:2014-12-27 08:58:27
【问题描述】:
我想根据传递给函数的员工 ID 数组来限制游标结果集,否则如果数组 iks null 我想要所有记录。
这是我尝试过的东西
首先创建数组类型
create or replace type p_emp_arr as table of number
功能是
create or replace
FUNCTION getEmployee_func ( empID IN Number, empId_arr IN p_emp_arr)
RETURN number IS
total number(2) := 0;
BEGIN
IF(empId_arr is null)
THEN
CURSOR empCursor IS
SELECT * FROM Employee ;
ELSE
CURSOR empCursor IS
SELECT * FROM Employee where empId in (p_emp_arr);
END IF;
....
RETURN total;
END;
但是遇到错误
Error(12,12): PLS-00103: Encountered the symbol "empCursor" when expecting one of the following: := . ( @ % ;
【问题讨论】:
-
您应该在 PLSQL 块的声明部分声明
Explicit Cursor
标签: oracle function plsql cursor