我创建了一个存储过程如下:CREATE PROCEDURE LEAVE_LOOP ( deptin char(3), out p_counter integer)
DYNAMIC RESULT SETS 1
------------------------------------------------------------------------
-- SQL Stored Procedure
------------------------------------------------------------------------
P1: BEGIN
declare v_at_end, v_counter integer default 0;
declare v_lastname varchar(15);
declare v_birthd, v_hired date;
-- Declare cursor
DECLARE c1 CURSOR WITH RETURN FOR
SELECT workdept, lastname, hiredate, birthdate from employee
where workdept=deptin;
declare continue handler for not found set v_at_end = 1;
-- Cursor left open for client application
OPEN c1;
fetch_loop: loop
fetch c1 into v_lastname, v_hired, v_birthd;
if v_at_end <> 0 then leave fetch_loop;
end if;
set v_counter =v_counter + 1;
insert into cys.report_info_dept values(v_lastname, v_hired,v_birthd);
end loop fetch_loop;
set p_counter = v_counter;
END P1
存储过程创建成功,但是当我调用的时候 call cys.leave_loop('D11', p), 总是报错说:
call cys.leave_loop('D11', p)
"P" is not valid in the context where it is used.. SQLCODE=-206, SQLSTATE=42703, DRIVER=3.58.81
请问调用的时候该如何处理?
------解决方案--------------------------------------------------------
传递一个?
call cys.leave_loop('D11', ?)
------解决方案--------------------------------------------------------
call cys.leave_loop('D11', ?)
或者在程序里预先定义P,然后调用call cys.leave_loop('D11', p)