Hi All
I have one STATES table with two fields (STATECODE, NAME).
I had written following stored procedure on this table
CREATE PROCEDURE ESCRIP.STATES_GETALL(OUT @ERRORCODE INT, OUT
@ERRORDESCRIPTION VARCHAR(200))
LANGUAGE SQL
READS SQL DATA
DYNAMIC RESULT SETS 1
------------------------------------------------------------------------
-- This stored procedure return all rows from STATE table
-- Created by Suresh
-- Created Date 05/17/2006
-- Version 1.0
------------------------------------------------------------------------
P1: BEGIN
DECLARE SQLCODE INT DEFAULT 0;
DECLARE SQLSTATE CHAR(5) DEFAULT '00000';
DECLARE CURSTATE CURSOR WITH RETURN TO CALLER FOR SELECT STATECODE,
NAME FROM ESCRIP.STATES ORDER BY STATECODE WITH CS;
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
SET @ERRORDESCRIPTION=SQLSTATE;
SET @ERRORCODE = SQLCODE;
END;
OPEN CURSTATE;
SET @ERRORCODE = SQLCODE;
END P1
This stored procedure retuens me CURSOR .
But when STATES table is in 'check pending state' this stored procedure
gives me SQLTATE error though i had written exit handler for the stored
procedure.
As per my expectation it should return me SQLCODE and SQLSATE in output
parameter.
So please explain me what is problem in this stored procedure.
Thanks
Suresh