Solved

Link between QSYS2 and PF/LF defintion

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

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 32

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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

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 (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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

706 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now