473,471 Members | 4,687 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Problem with Global Temporary Table

I am creating a procedure A which is creating a global temporary table
DECLARE GLOBAL TEMPORARY TABLE session.temp (Service CHAR(2),
CustomerServiceTypeId INTEGER)
WITH REPLACE
ON COMMIT PRESERVE ROWS;

I am able to compile the proceudre.

But when I try to compile procedure B which is referencing the
temporary table in procedure A, I get the error.
"SESSION.TEMP" is an undefined name.

In procedure B all I am trying to do is
INSERT INTO session.temp VALUES ('MS', 0);
Can some one please help

Apr 5 '06 #1
2 4099
chettiar wrote:
I am creating a procedure A which is creating a global temporary table
DECLARE GLOBAL TEMPORARY TABLE session.temp (Service CHAR(2),
CustomerServiceTypeId INTEGER)
WITH REPLACE
ON COMMIT PRESERVE ROWS;

I am able to compile the proceudre.

But when I try to compile procedure B which is referencing the
temporary table in procedure A, I get the error.
"SESSION.TEMP" is an undefined name.


Try to add this in procedure B before the temp table is used:

IF 1 = 0 THEN
DECLARE GLOBAL TEMPORARY TABLE session.temp (Service CHAR(2),
CustomerServiceTypeId INTEGER)
WITH REPLACE
ON COMMIT PRESERVE ROWS;
END IF

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Apr 5 '06 #2
chettiar wrote:
I am creating a procedure A which is creating a global temporary table
DECLARE GLOBAL TEMPORARY TABLE session.temp (Service CHAR(2),
CustomerServiceTypeId INTEGER)
WITH REPLACE
ON COMMIT PRESERVE ROWS;

I am able to compile the proceudre.

But when I try to compile procedure B which is referencing the
temporary table in procedure A, I get the error.
"SESSION.TEMP" is an undefined name.

In procedure B all I am trying to do is
INSERT INTO session.temp VALUES ('MS', 0);

You have two choices:
Use dynamic SQL to break teh static dependency.
DECLARE the temp table before running the CREATE PROCEDURE statement.
DB2 needs to have all DDL objects defined to do proper name and function
resolution.

I recommend to customers to concentrate all temp table defintion that
are used across multiple procedures to have a dedicated DDL procedure.
Before creating any procedure you simply CALL the DDL procedures and you
know you got what you need.
Also when executing the app you CALL that same procedure at the right time.

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Apr 5 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Jim Garrison | last post by:
Scenario: 1) Create a GLOBAL TEMPORARY table and populate it with one (1) row. 2) Join that table to another with about 1 million rows. The join condition selects a few hundred rows. ...
10
by: Ranga | last post by:
I was unable to run the statement "CREATE GLOBAL TEMPORARY TABLE" on unix version of DB2, it gave the follwing error db2 => create global temporary table temp ( OGI_SYS_NR char(8) ) DB21034E ...
11
by: Hemant Shah | last post by:
Folks, I have a perl script that creates and uses global termporary table. This script worked fine with UDB 7.2 on AIX. Sometime ago I moved the database to UDB 8 on Linux. The select statement...
2
by: Chuck Crews | last post by:
I am interested in declaring a global temporary table within an application. The application processes 1 set of 600 or less rows each iteration. Multiple programs can and do call this one...
1
by: abh1508 | last post by:
Following a release of code the following problem occurs on certain asp ..net pages. This is not a problem on other testing/demo environments. IIS seems to be creating certain files twice in the...
2
by: David Parker | last post by:
In our application we have a table that tracks network sessions. The usage is: 1) create a session record 2) read/update the record several times during the session 3) delete the session record...
0
by: sgueder | last post by:
Hi there, hope anybody can help me: I want to create a temporary table, want to fill that table with data and finally I want to use that table as my base-table for running some selects on it...
5
by: Rahul B | last post by:
Hi, I have very little knowledge about creating Procedures/functions in DB2. When i tried to create the test function like CREATE FUNCTION GET_TEST (P_TEST_ID INTEGER, P_SEL_OR_SORT...
1
by: Ragianand | last post by:
Hi All, I have created a stored procedure which populates a global emporary table...Now i want to write a function which returns a view that contains the data from the global temporary table.Can...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.