在调用现有程序包中的函数时遇到此错误。
包装的代码
CREATE OR REPLACE PACKAGE BODY calc
IS
FUNCTION emp_details (e_id INTEGER)
RETURN v_varr
IS
CURSOR c_emp IS
SELECT first_name, last_name, email
FROM emp_data
WHERE employee_id = e_id;
v_val v_varr;
err_msg VARCHAR2 (400);
BEGIN
v_val :=
v_varr (NULL,
NULL,
NULL
);
DBMS_OUTPUT.put_line('Inside function: ');
FOR c1 IN c_emp
LOOP
v_val (1) := c1.first_name;
v_val (2) := c1.last_name;
v_val (3) := c1.email;
END LOOP;
EXCEPTION
WHEN OTHERS
THEN
err_msg := SUBSTR (SQLERRM, 2, 300);
DBMS_OUTPUT.put_line ('Error: ' || err_msg);
RETURN v_val;
END emp_details;
END calc;
调用时出错。
DECLARE
TYPE v_vall IS VARRAY (3) OF VARCHAR (50);
v_call v_vall;
err_msg varchar2(100);
BEGIN
v_call := calc.emp_details (109);
DBMS_OUTPUT.put_line (v_call (1) || v_call (2) || v_call (3));
EXCEPTION
WHEN OTHERS
THEN
err_msg := SUBSTR (SQLERRM, 2, 300);
DBMS_OUTPUT.put_line ('Error: ' || err_msg);
END;
在此行出现错误:
v_call := calc.emp_details (109);