IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

How temporary tables can be used in DB2


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Souvik Chanda

New User


Joined: 11 Oct 2007
Posts: 1
Location: Kolkata, India

PostPosted: Fri Oct 12, 2007 12:59 pm
Reply with quote

Can anybody tell how temporary tables can be used? I would like to know all the necessary steps required to use DB2 temporary tables in a program. Which one is a better approach - using a created temp. table or a declared temp. table? Would be very very thankful if I get a detailed answer.
Back to top
View user's profile Send private message
ksk

Active User


Joined: 08 Jun 2006
Posts: 355
Location: New York

PostPosted: Fri Oct 12, 2007 2:39 pm
Reply with quote

You can use array to load all the data of a table and u can use the same in the COBOL program.
Back to top
View user's profile Send private message
dr_te_z

New User


Joined: 08 Jun 2007
Posts: 71
Location: Zoetermeer, the Netherlands

PostPosted: Fri Oct 12, 2007 4:57 pm
Reply with quote

At my site they always use "declared". Dunno why.
It works great, I'm using it more and more. Just
Code:
EXEC SQL DROP      TABLE SESSION.Q_TMP                 
END-EXEC                                                     
EXEC SQL DECLARE                                             
  GLOBAL TEMPORARY TABLE SESSION.Q_TMP                 
       ( THIS           SMALLINT   NOT NULL DEFAULT 9 
       , THAT           CHAR (006) NOT NULL           
       , WHATEVER       CHAR (004) NOT NULL)

e.g. when you have a complex query where you need info from "outside DB2" just gather that info into such a table and include/join that in your query.
Be ware that DB2 will treat that whole query as dynamic SQL! (empty plan-table)
Back to top
View user's profile Send private message
nuthan

Active User


Joined: 26 Sep 2005
Posts: 146
Location: Bangalore

PostPosted: Fri Oct 12, 2007 5:10 pm
Reply with quote

Make use of this link.

www.cs.newpaltz.edu/~pletcha/DB/db2_TempTables.html
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Need to fetch data from so many DB2 t... DB2 9
No new posts How to: PK does not exist in several ... DB2 6
No new posts Discrepancy b/w SYSIBM tables and BMC... DB2 0
No new posts SYSIBM Tables Query DB2 8
No new posts Column names in SYSIBM tables DB2 5
Search our Forums:

Back to Top