Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Link between QSYS2 and PF/LF defintion

Posted on 2004-04-13
5
Medium Priority
?
1,189 Views
Last Modified: 2008-03-17
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.
0
Comment
Question by:sixeyed
  • 2
5 Comments
 
LVL 33

Expert Comment

by:shalomc
ID: 10890650
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
 

Author Comment

by:sixeyed
ID: 10893383

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
 
LVL 33

Accepted Solution

by:
shalomc earned 2000 total points
ID: 10894519
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

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

November 2009 Recently, a question came up in the DB2 forum regarding the date format in DB2 UDB for AS/400.  Apparently in UDB LUW (Linux/Unix/Windows), the date format is a system-wide setting, and is not controlled at the session level.  I'm n…
Recursive SQL in UDB/LUW (it really isn't that hard to do) Recursive SQL is most often used to convert columns to rows or rows to columns.  A previous article described the process of converting rows to columns.  This article will build off of th…
Integration Management Part 2
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

927 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question