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 > SQLCODE -204 due to Declare Global Temporary Table

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-20-10, 23:56
upendra_water upendra_water is offline
Registered User
 
Join Date: Dec 2010
Posts: 10
SQLCODE -204 due to Declare Global Temporary Table

Hi,

In my project a Declare Global Temporary Table is used in a stored procedure.
This DGTT is created in procedure "A" and used in procedures "B" and "C". These 3 SPs are called from dotNET application one by one i.e. first A then B then C.
Procedures "A" and "B" complete successfully but "C" fails with SQLCODE -204 because DGTT is getting deleted.
I have 2 questions:
1) Why DGTT is getting dropped.
2) Is there any way to prevent it from getting dropped?
Reply With Quote
  #2 (permalink)  
Old 12-21-10, 07:53
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Quote:
Originally Posted by upendra_water View Post
This DGTT is created in procedure "A"
A declared temporary table is never created - that's why it is called "declared". It needs to be declared, subsequently, in every routine that references it.
Reply With Quote
  #3 (permalink)  
Old 12-21-10, 11:28
Lenny77 Lenny77 is offline
Registered User
 
Join Date: Jul 2009
Location: NY
Posts: 886
Lightbulb

Quote:
Originally Posted by upendra_water View Post
Hi,

In my project a Declare Global Temporary Table is used in a stored procedure.
This DGTT is created in procedure "A" and used in procedures "B" and "C". These 3 SPs are called from dotNET application one by one i.e. first A then B then C.
Procedures "A" and "B" complete successfully but "C" fails with SQLCODE -204 because DGTT is getting deleted.
I have 2 questions:
1) Why DGTT is getting dropped.
2) Is there any way to prevent it from getting dropped?
I beleive somewhere COMMIT happened.

Try to use:
Code:
Declare global temporary table DGTT (.....)
on commit preserve rows;
Lenny
Reply With Quote
  #4 (permalink)  
Old 12-21-10, 12:43
upendra_water upendra_water is offline
Registered User
 
Join Date: Dec 2010
Posts: 10
Hi,
We have already used ON COMMIT PRESERVE ROWS option while declaring TEMP table. When the number of rows in TEMP table are very few, all stored procedures execute successfully. The problem occurs only when there are thousands of rows in TEMP table. In 1 case we found that there were 12000 rows in TEMP table and the stored procedure failed i.e. "A" and "B" execute successfully but "C" fails.
Reply With Quote
  #5 (permalink)  
Old 12-21-10, 15:09
Lenny77 Lenny77 is offline
Registered User
 
Join Date: Jul 2009
Location: NY
Posts: 886
Quote:
Originally Posted by upendra_water View Post
Hi,
We have already used ON COMMIT PRESERVE ROWS option while declaring TEMP table. When the number of rows in TEMP table are very few, all stored procedures execute successfully. The problem occurs only when there are thousands of rows in TEMP table. In 1 case we found that there were 12000 rows in TEMP table and the stored procedure failed i.e. "A" and "B" execute successfully but "C" fails.
Because of it's happen when global table is huge, maybe you have
sqlcode = -904 (resourse unavailabe) which you do not catch, and than sqlcode = -204.

Lenny
Reply With Quote
  #6 (permalink)  
Old 12-21-10, 16:03
upendra_water upendra_water is offline
Registered User
 
Join Date: Dec 2010
Posts: 10
Hi,

We are getting SQLCODE -204 only. Please see screenshot from DB2 logs.
Attached Thumbnails
SQLCODE -204 due to Declare Global Temporary Table-sqlcode-204.jpg  
Reply With Quote
  #7 (permalink)  
Old 12-21-10, 16:11
upendra_water upendra_water is offline
Registered User
 
Join Date: Dec 2010
Posts: 10
Attaching 1 more screenshot which shows the exact error.
It shows that the temp table is undefined.
Attached Thumbnails
SQLCODE -204 due to Declare Global Temporary Table-sqlcode-204.jpg  
Reply With Quote
  #8 (permalink)  
Old 12-21-10, 16:46
Lenny77 Lenny77 is offline
Registered User
 
Join Date: Jul 2009
Location: NY
Posts: 886
Quote:
Originally Posted by upendra_water View Post
Attaching 1 more screenshot which shows the exact error.
It shows that the temp table is undefined.
Undefined after destroyed in SP "B"....
Reply With Quote
  #9 (permalink)  
Old 12-21-10, 17:14
upendra_water upendra_water is offline
Registered User
 
Join Date: Dec 2010
Posts: 10
Hi Lenny,
That's what is puzzling me. Why this table is getting dropped in third SP?
When the number of rows are less in temp table all three SPs execute successfully and we get proper reports from front end. Only when the number of rows are huge we face this error.
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