Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Building a DB2 table

Status
Not open for further replies.

CT004691

Programmer
Jan 10, 2003
17
GB
I wish to build a temporary DB2 table whilst executing a batch cobol program. I want to do this in the program rather than have a DBA create it becuase the data is "unique" to this program. I want to interrogate an internal array several times and it'll be much easier to do it with a DB2 table than a cobol array.

Any suggestions are am I talking pie in the sky?
 
You have 2 options as regards temporary tables.

You can have the DBA declare them up front for you, meaning your program doesn't have to bother with the declaration. As far as programming goes you treat them as you would any other table, the only difference being when you use them you will see only your UOW on there, not anyone elses.

Or you can declare them in your program, where they are available for your sole use.

Cheers
Greg
 
Hi,

Would the following statement suffice:

CREATE GLOBAL TEMPORARY TABLE.....

Regards,

Mike.
 
Mike,

it should do. There are two kinds of temporary tables:

Created temporary tables, which you define using a CREATE GLOBAL TEMPORARY TABLE statement (introduced in DB2 V5 as global temporary tables).

Declared temporary tables, which you define in a program using a DECLARE GLOBAL TEMPORARY TABLE statement (DB2 V6 and later).
SQL statements that use temporary tables can run faster, because:
There is no logging for created temporary tables. Only UNDO records (required for rollback processing) are logged for declared temporary tables.

There is no locking for created temporary tables and only share level locks for declared temporary table spaces.

Cheers
Greg
 
Mike,

I believe it would. There are two kinds of temporary tables:

Created temporary tables, which you define using a CREATE GLOBAL TEMPORARY TABLE statement (introduced in DB2 V5 as global temporary tables).

Declared temporary tables, which you define in a program using a DECLARE GLOBAL TEMPORARY TABLE statement (DB2 V6 and later).
SQL statements that use temporary tables can run faster, because:
There is no logging for created temporary tables. Only UNDO records (required for rollback processing) are logged for declared temporary tables.

There is no locking for created temporary tables and only share level locks for declared temporary table spaces.

Cheers
Greg
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top