Ok, this may come as a surprise to you, but the OS comes with a built in
database called DB2.
DB2, like many other databases, has something called a "system catalog".
You may read about it at:
http://www-01.ibm.com/support/knowledgecenter/api/content/ssw_ibm_i_72/db2/rbafzcatalog.htm

One very interesting view is SYSCOLUMNS. You can read about it at:
http://www-01.ibm.com/support/knowledgecenter/api/content/ssw_ibm_i_72/db2/rbafzcatsqlcolumns.htm

One sample way to look at it is with
SELECT SYSTEM_COLUMN_NAME, SYSTEM_TABLE_NAME, SYSTEM_TABLE_SCHEMA
FROM syscolumns
WHERE system_column_name like('ABC%')
If I change ABC to IM I can see
....+....1....+....2....+....3....+....4....+....5....+...
SYSTEM_COLUMN_NAME SYSTEM_TABLE_NAME SYSTEM_TABLE_SCHEMA
IMID @IML01 ACCFILV404
IMMSTP @IML01 ACCFILV404
IMPART @IML01 ACCFILV404
IMPTYP @IML01 ACCFILV404
IMALOT IIML01 BPCS405CDF
IMASTB IIML01 BPCS405CDF
IMAXP IIML01 BPCS405CDF
...

Now, if I just wanted this for one particular library I could do something
like this
SELECT SYSTEM_COLUMN_NAME, SYSTEM_TABLE_NAME, SYSTEM_TABLE_SCHEMA
FROM syscolumns
WHERE system_column_name like('IM%')
AND SYSTEM_TABLE_SCHEMA='BPCS405CDF'
Now, if I only wanted the table name once, and not repeatedly for each
column it has that matches, I could do this
SELECT SYSTEM_TABLE_NAME
FROM syscolumns
WHERE system_column_name like('IM%')
AND SYSTEM_TABLE_SCHEMA='BPCS405CDF'
group by SYSTEM_TABLE_NAME
SYSTEM_TABLE_NAME
IIML01
IIML02
IIML03
...

This is the simple stuff. The hard stuff is understanding your record
inclusion you mentioned.
Are you saying that if I find a table, with these columns: ABCPER1,
ABCPER2, ABCPER3, ABCYTD
then you want to copy all the rows out of this table which match a certain
criteria? how? Meaning, if the criteria is
ABCPER3>10000
then why are you searching for all column names beginning with ABC?
Wouldn't you need that exact column?
Or, are you really lucky and you want all tables with ABCPER1 through
ABCPER12 and ABCYTD in which any of those columns have a value of 10000 or
more?



Rob Berendt

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 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.