Need Solution/reason for "7609: Fetch statement is incompatible with current CURSOR definition"

Database

Need Solution/reason for "7609: Fetch statement is incompatible with current CURSOR definition"

REPLACE PROCEDURE MyDataBName.sp1 (IN parIn1 VARCHAR(100), OUT par1 VARCHAR(30), OUT Par2 VARCHAR(30))
BEGIN
DECLARE CurStr VARCHAR(500);
DECLARE projcursor CURSOR FOR S1;

SET CurStr = MyQuery;

PREPARE S1 FROM CurStr;
OPEN projcursor;
Label1:
LOOP
FETCH projcursor INTO par1, par2;
IF (SQLSTATE = '02000') THEN LEAVE label1; END IF;
END LOOP label1;
CLOSE projcursor;
END;

MyQuery  contains the select statement with "where" clause. I m using LIKE to fliter the records base on parIn1 .

Thanks

1 REPLY
Junior Contributor

Re: Need Solution/reason for "7609: Fetch statement is incompatible with current CURSOR definition"

From the Messages manual:

 

7609 Fetch statement is incompatible with current CURSOR definition.

Explanation: At runtime, the FETCH statement considers the compile-time definition of the tables used in the cursor

SELECT statement. The table definitions may change at runtime and may not be compatible in terms of data types or sizes

with the definition assumed by the FETCH statement.

Generated By: RTS modules.

For Whom: End User.

Remedy: Recreate the Stored Procedure with current table definition and resubmit the request.

The datatypes of par1 and pa2 are probably not matching the column definition.

Btw, i would prefer FOR or WHILE over LOOP for cursor processing.

Dieter