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!

Insert to multiple DB2 tables with same structure in COBOL.

Status
Not open for further replies.

mattbarnes

Programmer
Dec 27, 2004
1
US
Hi all.

I have an issue in COBOL. I have 12 tables, aptly named Table01, Table02, Table03, etc based on the month of the year.

In my cobol code, I specify:

EXEC SQL
INSERT INTO TABLE01
(field1,
field2,
etc)

I also want to be able to insert to another table (February for instance) with the exact same data... My question is... Do I need to create an entirely new DB2 Insert structure replacing the table name or can I use the same structure with the table name being a variable of some sort?

The issue comes in that I have 12 tables. All 12 tables have the same 50 fields. I would hate to have 12 inserts to the tables, listing all 50 fields 12 times.

Any help?

 
The answer is yes, that is what is call dynamic sql. The IBM has information about that. You need to keep in mind that it will run a tich slower because of binding.
 
If it needs to be prepared every time, it will be slower. But if you are going to prepare it once, then use the statement to insert 5000 rows into the February table one after the other, then you probably won't even notice it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top