Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to use Temporary tables with Cursors ?

Status
Not open for further replies.

RomanPr

Programmer
Jun 22, 2004
1
US
Hi All,
I'm new to DB2 stored procedures. I'm trying to create a temporary table, then select data into it from number of different tables, than return result as a ResultSet into Java application.

Here is the procedure, it's jut a draft. But it doesn't compile. Without Declare temporary table statement it works. But after I declare MYTEMP table procedure gives me an error during compilation. It's complaining about cursor.
I'm I doing somethign wrong ?


CREATE PROCEDURE ROMAN.TEST ( INOUT PARAMETER1 INTEGER )
RESULT SETS 0
LANGUAGE SQL
SPECIFIC ROMAN.TEST
BEGIN
DECLARE VARIABLE1 DECIMAL ( 5 , 4 ) ;
DECLARE GLOBAL TEMPORARY TABLE MYTEMP LIKE CAC ;

DECLARE cursor1 CURSOR FOR
SELECT CACB#, CACID, CACX#, CACDAT, CACTIM, CACBDT, CACSTS, CACCDT, CACCTM, CACTST, CACCME, CACCMD, CACCMT, CACPME, CACPMD, CACPMT FROM CAC ;

-- Cursor left open for client application
OPEN cursor1;


END


Thanks,
Roman Pr.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top