Quote:
Is there a reason you cannot use a join and make the stmts into a single cursor....? Just out of curiosity
Cheers
Sathyaram
|
I can well try with a join too.. jus to know how it works with a separate cursor,...
I have another query regarding the cursors and temporary tables.. jus follow the below steps
1. I declare a global temp. table in a procedure P1
2. From P1 I call another procedure P2
3. In P2 i ve the following Insert statement to populate the data into temp table in P1
Code:
INSERT INTO SESSION.TEMPTAB
SELECT COL1 FROM LOCTAB
WHERE COLID = var
4. now in P1 i open the cursor declared with the select query
Code:
CREATE PROCEDURE P1
(
IN var smallint;
)
SPECIFIC P1
DYNAMIC RESULT SETS 1
LANGUAGE SQL
BEGIN
DECLARE SQLCODE INTEGER DEFAULT 0;
DECLARE S_SQLCODE INTEGER DEFAULT 0;
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION, SQLWARNING, NOT FOUND
SET S_SQLCODE= SQLCODE;
DECLARE GLOBAL TEMPORARY TABLE SESSION.TEMPTAB
(
col1 smallint
) WITH REPLACE ON COMMIT PRESERVE ROWS NOT LOGGED;
BEGIN
DECLARE S_Temp_Cursor0 CURSOR WITH HOLD WITH RETURN TO CLIENT FOR SELECT * From SESSION.TEMPTAB;
CALL P2(var);
OPEN S_Temp_Cursor0 ;
RETURN 0;
END;
END
@
The select query in step (3) returns the column value of just two rows.. but the result set returned by the procedure P1 has all the rows of LOCTAB table...
Am i missing some thing..
Regards
Sn