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

Help needed in developing an utility 1

Status
Not open for further replies.

jackooo

Programmer
Oct 22, 2003
3
IN
Hi,

i am intended to develop an utility which does the following functionality. Reads a table and constructs the insert statements from that table entries. this utility will take table name as its input and constructs a flat file which contains the insert statements for that Table.

i have identified the key functions in that utility:

1) Get the description(number of fields and the attributes of those fields) of the table.

2)construct an dynamic sql CURSOR to fetch the values from that Table.

3) construct the format of the insert statement.

4) write it in a File.

As this utility has to do the functionality irrespective of any table (Dynamically) Please suggest me some ideas in doin the first Step.
also if u have done this previously please suggest me some guidelines in implementing the same

PLATFORM-MAINFRAMES OS/390
Language:COBOL/DB2


 
friends,
this is a follow up to the previous message.. there are tables like SYSTABLES which describe the properties of the table.. similarly is there any table which gives us the details (attributes , EG,DATE,VARCHAR ) of the fields in the Table..

Thanks,
Jack
 
Depending on which flavor of Relational Database Management System you are dealing with, there could be just as many solutions - so I will try not to venture one without knowing more about your set-up.

Ok, here is one way anyway. It's ODBC leaning.

1. Using variables that contain the table name, construct a SELECT * statement.

2. At this point, the following results are available from the methods and properties of the record set: how many columns are there, what are their names, what data types are they, etc...

Your first step is therefore connecting to and opening the database.

Dimandja
 
Dimandja
Actually its DB2 so u can mention the Select ststaement which gets me those details.

Regards..
 
Jackoo,
I'm not 100% sure of what it is you are trying to achieve as an end result. From your post it looks as if you wish to have the name of a db2 table input to the utility, and then the utility will interogate the data on the table, creating a flat file of insert statements for the the existing data on the table. Have I got this correct?
Marc
 
This sounds like a problem for REXX not COBOL, if you have that language available. I have done many similar things with REXX, it is the ideal way to solve such problems.
 
Actually I have done all the things needed here, in COBOL, on many different occasions - I never felt that COBOL was restricted in any way. It's actually a job that COBOL handles very well.

Constructing an SQL SELECT/INSERT statement is done quite regularly in COBOL. See coding embedded/dynamic SQL in COBOL. I (and many others) have done this too many times.

Dimandja
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top