I want to go through all records from a cursor in a while loop but I don't know how to stop this loop I have read in my book I shall use SQLSTATE but how? Below is my code. I'm trying to check SQLSTATE S1000 but I still receive error :
ODBC Error: SQLSTATE = S1000, Native error code = -5004
No data found.
I run this procedure in the Pervasive Control Center.
ODBC Error: SQLSTATE = S1000, Native error code = -5004
No data found.
I run this procedure in the Pervasive Control Center.
Code:
CREATE PROCEDURE MyProc() AS
BEGIN
DECLARE MyCursor CURSOR FOR SELECT MyField FROM MyTable;
DECLARE :vField char(1);
DECLARE :vEnd int;
SET :vEnd=0;
OPEN MyCursor;
FETCH NEXT FROM MyCursor INTO :vField;
WHILE (:vEnd=0) DO
PRINT :vField;
FETCH NEXT FROM MyCursor INTO :vField;
IF (SQLSTATE='S1000')THEN
SET :vEnd=1;
END IF;
END WHILE;
CLOSE MyCursor;
END;