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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

db2 procedures - export + variable

Status
Not open for further replies.

saltbits

Programmer
Jun 1, 2004
27
US
my requirement:
i have to generate a flat file from some simple Table1. then i need to insert into Table2 a record for every record from Table1 that was exported (Table2 is kind of a status table). so the steps would be:
#1. EXPORT TO (that includes a SELECT from Table1)
#2. UPDATE Table2 with PK of Table1 as foreign

for doing #2, i need to store the PKs from the SELECT statement into some (sqltable)variable. using Stored Procedures, this must be simple. but Stored Procedures do not allow the EXPORT statement in them. i know there must be some easy way of doing this but i am simply new to databases, especially db2. can someone please help?!
thanks very much.
 
Are you going to do this on two separate databases or just on one database?
 
i should be more clear. Table2 is NOT the table that i am intending to load with the data from Table1. Table2 is simply a way to remember that certain records from Table1 have been selected for exporting to a remote. basically, its a flag table that stores values like 'in process of exporting', 'exported successfully', 'export failed' etc. with the PK from Table1 for reference.

thanks for the help.
 
Okay, I'm confused. Is there a Table 3 in the mix here? Is this something you want to be a repeatable process, thus the stored procedure?
 
no there is no Table3. i dont even know if i need a Stored Procedure anymore. i assumed that the only way db2 allowed using variables was through SP. is there another way to do all this without a SP. the process is repeatable, though and we were planning on putting things in a sheel script...
 
thanks prusqler - i got it done anyway - using global temp tables. thanks for the time, though.
 
I was going to suggest global temp tables or table expressions but couldn't quite figure out what you were attempting. Anyway, glad you worked it out.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top