If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > DB2 Temporary Table existence problem

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-16-09, 08:01
firebal firebal is offline
Registered User
 
Join Date: Jul 2009
Posts: 2
DB2 Temporary Table existence problem

Hi,
I'm having some problems with temporary table in DB2, web application, dll and stored procedure.
Here is the environment:
Machine1 - BD Server
Machine2 - Web (IIS and web application).

During the execution of the web application in a C# DLL, it calls a Delphi DLL (that creates all the temporary tables) and calls a stored procedure (sp1 who calls sp2 e it goes on). Inside the sp, a Delete statement from the temporary table is executed, but when it will be done an error occurs saying that the temporary table doesn't exists.

Does anyone have any idea why it's happening? Could it be some session problem (the creation of the temporary table occurs on one session inside the web machine, and the execution of the SP occurs in another session on the BD machine) ?

Does DB2 have any "global" temporary table like MS SQL Server (represented by ##), and if it exists, it will help me??

Thank you.

[]s
Reply With Quote
  #2 (permalink)  
Old 07-16-09, 08:13
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
You are correct. it is a session problem. The temporary tables of one session cannot be used by another. No there is no structure outside a normal persisted table that all sessions can access.

Andy
Reply With Quote
  #3 (permalink)  
Old 07-16-09, 08:40
firebal firebal is offline
Registered User
 
Join Date: Jul 2009
Posts: 2
But even if I'm on the same connection? Or the execution of the procedure "looks like" another session/connection?
Reply With Quote
  #4 (permalink)  
Old 07-16-09, 09:02
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
Declared temporary tables (created by DECLARE GLOBAL TEMPORARY TABLE) are accessible only on the same connection that they are created in. If two separate connections each issue the exact DECLARE GLOBAL TEMPORARY TABLE statement, they are each accessing their own object and cannot even see the other connection's object.

So if you are creating a temp table like this in one session and another session cannot see it, then there are only two possible answers. 1) the sessions are on different connections or 2) the temporary table was dropped, either implicitly through a disconnect or explicitly with a drop table command. If it was dropped implicitly, then you are using a different connection anyway.

Andy
Reply With Quote
  #5 (permalink)  
Old 07-17-09, 10:12
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Let's clarify the term "connection" here. Temp tables are bound to the connection _to_ DB2, i.e. the connection that the web server establishes to the database. It is not the connection from your web client to the web server. With that in mind, you will have to make sure that the web server doesn't use multiple different threads to answer a web client's request because each thread will (typically) have a different DB2 connection.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On