DB2 - SQL Stored Procedure for clien application - does not return column names

greenspun.com : LUSENET : DBAzine : One Thread

Hello, We built a DB2 SQL stored procedure (using Stored Procedure builder) to return a resultset to a calling java application. The stored proc opens a cursor and leaves it open, as per the guidelines in the DB2 Application Guide. The resultset gets created successfully but the column names contain 1,2,3 etc instead of actual column names. Is there some option that needs to be specfied to return the column names also? Below is a sample of the procedure:

CREATE PROCEDURE xxxxxx.GET_ELIG_ERR ( INOUT TID CHAR(9), OUT SQLSTATE_OUT CHAR(5), OUT SQLCODE_OUT int) RESULT SETS 1 LANGUAGE SQL MODIFIES SQL DATA COLLID xxxxxx EXTERNAL NAME 'getelerr' WLM ENVIRONMENT xxxxxxxx ASUTIME NO LIMIT RUN OPTIONS 'NOTEST(ALL,*,,VADTCPIP&99.9.99.99:*)' ------------------------------------------------------------------------ -- SQL Stored Procedure ------------------------------------------------------------------------ P1: BEGIN DECLARE SQLCODE INT DEFAULT 0; DECLARE SQLSTATE CHAR(5) DEFAULT '00000';

DECLARE cursor1 CURSOR WITH HOLD WITH RETURN FOR SELECT TID, CLNUM, ERR_TXT FROM VXM003 A, VXM002 B WHERE A.ERR_NUM = B.ERR_NUM

AND A.ERR_NUM < 100; --Declare Error Handlers DECLARE EXIT HANDLER FOR SQLEXCEPTION SELECT SQLSTATE, SQLCODE INTO SQLSTATE_OUT, SQLCODE_OUT FROM SYSIBM.SYSDUMMY1; DECLARE CONTINUE HANDLER FOR SQLWARNING SET SQLCODE_OUT = SQLCODE; DECLARE CONTINUE HANDLER FOR SQLSTATE '42704' SET SQLCODE_OUT = SQLCODE;

--Leave cursor open for clien application OPEN cursor1; SET SQLSTATE_OUT = SQLSTATE; SET SQLCODE_OUT = SQLCODE; END P1

-- Beena Kannusamy (Beena.Kannusamy@mutualofomaha.com), August 19, 2003


Moderation questions? read the FAQ