Link between QSYS2 and PF/LF defintion

Hi,

I'm hoping to navigate the INFORMATION_SCHEMA views (QSYS2 in DB2/400) to get table constraint information.

Currently I want to be able to get the primary key for a table - which is availabe in TABLE_CONSTRAINTS (QSYS2.SYSCST), where CONSTRAINT_TYPE = 'PRIMARY KEY'.

However, in the catalog I'm accessing, there are no entries for tables created through DDS - where I would expect to find PRIMARY KEY entries for key/unique fields defined in PF and LF source.

Is there any mapping between the DDS and constraint entries in the catalog?

I'm aware of API QSQGNDDL, but I'm aiming to get the information from the ANSI-standard views if I can.

Any pointers would be apprciated.

Thanks.
sixeyedAsked:
Who is Participating?
 
shalomcCTOCommented:
Technically speaking, you can execute any AS400 command via an ODBC connection.
An SQL command like

call qcmdexc('DSPFD FILE(yourlib/*ALL) TYPE(*ACCPTH) OUTPUT(*OUTFILE)  FILEATR(*PF *LF) OUTFILE(lib2/outf_name)', 0000000097.00000 )

will create an SQL retrievable table called outf_name in collection (library) lib2.

There is a column that indicates primary key existence, and another that indicates the existence of or lack of constraints.
This is the only method that supports DDS files, besides writing API programs.

ShalomC
0
 
shalomcCTOCommented:
sixeyed,
I checked my AS400 carefully, and found out that you are correct.
A workaround will be to run

 DSPFD FILE(yourlib/*ALL) TYPE(*ACCPTH) OUTPUT(*OUTFILE)  FILEATR(*PF *LF) OUTFILE(lib2/outf_name).

The resulting outfile has a flag that indicates whether there are constraints on the table.

In your report, you should be able to UNION this file with syscst, where there are unique keys and no constraint.

Shalom
0
 
sixeyedAuthor Commented:

Hi Shalom,

thanks for your answer.

Problem is, I'm trying to access metadata information on database structure through an OLE DB link, and executing AS/400 commands isn't an option.

Is there any SQL-retrievable store of PRIMARY KEY, FOREIGN KEY and COLUMN CONSTRAINT information, which is in line with PF/LF stucture?

I suspect there isn't, but I'm open to options.

Thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.