
July 25th, 2005, 11:03 AM
|
|
Contributing User
|
|
Join Date: Jun 2003
Location: Waco, Texas
|
|
I would think that you should declare and populate the global temp table first
fv
Quote: | Originally Posted by Supriyo I have a requirement where I have to populate a TEMPORARY TABLE and use the table in a CURSOR.
In a stored procedure it is mandatory to declare the CURSOR before I declare the the TEMPORARY TABLE. But it gives me an error:
"SESSION.TABLE_NAME" is an Undefined Name.
Following is the code:
CREATE PROCEDURE CORE.TEMP_TABLE_SP ( )
DYNAMIC RESULT SETS 1
------------------------------------------------------------------------
-- SQL Stored Procedure
------------------------------------------------------------------------
P1: BEGIN
DECLARE TEMP CURSOR FOR
SELECT * FROM SESSION.TEMP_SERVICE;
DECLARE GLOBAL TEMPORARY TABLE TEMP_SERVICE (ID_NUM INT) WITH REPLACE NOT LOGGED;
Delete from session.TEMP_SERVICE;
Insert into session.TEMP_SERVICE
VALUES(2);
OPEN TEMP;
END P1
Can any body help me?...... |
__________________
...because that is the way we have always done it. We've been doing it like that for 80 Years! (How do we change that mindset?)
|