|
Michael,
In a pinch, you could use the following SQL script to get your field info into
table (file)yourlibr/RCD_LAYOUT:
DROP TABLE yourlibr/rcd_layout; // do not do this the first time running the
script!
CREATE TABLE yourlibr/rcd_layout
(colno DEC (9,0) NOT NULL with default,
sys_dname CHAR (10) NOT NULL with default,
sys_tname CHAR (10) NOT NULL with default,
sys_cname CHAR (10) NOT NULL with default,
labeltext VARCHAR (50),
length DEC (9,0) NOT NULL with default,
coltype VARCHAR (8) NOT NULL with default,
scale DEC (9,0),
table_dsc CHAR (50) NOT NULL with default,
row_len DEC (9,0) NOT NULL with default,
col_count DEC (9,0) NOT NULL with default,
PRIMARY KEY(sys_dname, sys_tname, colno));
INSERT INTO yourlibr/rcd_layout
SELECT c.ordinal_position,
c.system_table_schema,
c.system_table_name,
c.system_column_name,
c.column_text,
c.length,
c.data_type,
c.numeric_scale,
t.table_text,
t.row_length,
t.column_count
FROM syscolumns c JOIN systables t
ON c.system_table_schema = c.system_table_schema
AND c.system_table_name = c.system_table_name
WHERE c.system_table_schema = 'your_library_name'
AND c.system_table_name = 'your_file-name'
ORDER BY c.system_table_name, c.ordinal_position;
Just put the above in a source member, then run the command:
RUNSQLSTM SRCFILE(srclibr/srcfile) SRCMBR(srcmbr) COMMIT(*NONE)
It works as a simple script as-is, or you can just use the SELECT in an
SQLRPGLE program to manipulate programatically. Using SQLRPGLE gives the
advantage of using substitution variables to make it generic.
Regards,
William
date: Fri, 4 Jun 2004 12:33:17 -0700 (PDT)
from: Michael Gottlieb
subject: (no subject)
Is there an API that can get me a list of fields in an externally-described
file? Any program examples will be a great help. Thanks!
Michael Gottlieb
gottlm@xxxxxxxxxxxxx
gottlm@xxxxxxxxx
Out of every 10 people, one understands binary, the other doesn't.
=============================
William Washington III
Njia Systems Incorporated
w.washington3@xxxxxxxxxxxxxxx
312-719-0519
=============================
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.