Solved

Link between QSYS2 and PF/LF defintion

Posted on 2004-04-13
5
1,162 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

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 (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…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

624 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