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 > Issue in Inserting data in GLOBAL TEMPORARY TABLE

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-14-04, 06:52
BKamesh BKamesh is offline
Registered User
 
Join Date: Jul 2004
Posts: 40
Issue in Inserting data in GLOBAL TEMPORARY TABLE

Following code snippet is used to create GLOBAL TEMPORARY TABLE, INSERT into the created temporary table, SELECT the same for the output.

db2 "declare global temporary table temp1(col1 integer,col2 varchar(30)) with replace"
db2 "insert into temp1 values(1,a)"
db2 "select * from session.temp2"

COL1 COL2
----------- ------------------------------

0 record(s) selected.

In the above SELECT statement output it shows "0 record(s) selected", after inserting a record previously.

What is the problem? Can any one resolve the same?.

Thanks,
Kamesh.
Reply With Quote
  #2 (permalink)  
Old 09-14-04, 08:29
vidyaraok vidyaraok is offline
Registered User
 
Join Date: Aug 2004
Posts: 15
the corrected statements are:


db2 "declare global temporary table temp1(col1 integer,col2 varchar(30)) with replace"

db2 "insert into session.temp1 values(1,'a')"
db2 "select * from session.temp1"
Reply With Quote
  #3 (permalink)  
Old 09-14-04, 08:37
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
Also on your DECLARE GLOBAL TEMPORARY TABLE statement, add the clause "ON COMMIT PRESERVE ROWS". Otherwise all the rows will be deleted when a commit/autocommit occurs.

Andy
Reply With Quote
  #4 (permalink)  
Old 10-18-04, 22:30
francis01 francis01 is offline
Registered User
 
Join Date: Jul 2004
Posts: 65
Unhappy

Hi BKamesh:

I have the same problem...did you solve it?
how?.

Thanks in advance...
Reply With Quote
  #5 (permalink)  
Old 10-25-04, 17:36
akkm akkm is offline
Registered User
 
Join Date: Oct 2004
Posts: 7
selecting records from DGTTs

Try auto commit off, when you running 'declare/insert/select sql'.

One way to this would be to execute query using file input on command line and use "db2 -e- -svtf input_file_nm.sql" command
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