Solved

Link between QSYS2 and PF/LF defintion

Posted on 2004-04-13
5
1,135 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 500 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Recursive SQL in UDB/LUW (you can use 'recursive' and 'SQL' in the same sentence) A growing number of database queries lend themselves to recursive solutions.  It's not always easy to spot when recursion is called for, especially for people una…
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…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

839 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