Newsletters Subscriptions Forums Media Kit About Us Contact Search Home

mgo
OS/400 Edition
Volume 3, Number 78 -- November 19, 2003

Querying the System Catalog Like DSPFD


Hey, Howard:

I liked your DSPDBR spreadsheet that called a stored procedure. Is it possible to do the same thing without calling the stored procedure, by querying the SYSTABLES or other system catalog file?

text

--John


You can't find the related tables in the SQL catalog views provided in the QSYS2 library. However, there are other catalog tables on the iSeries in the QSYS library. One file, QADBFDEP, describes how files are related to one another on the iSeries. The file contains fields for the file name (DBFIL), the library (DBFLIB), the dependent file (DBFFDP), and its library (DBFLDP). The following query will give you a list of files dependent on the IVPMSTR file in the library HD1100PD.

SELECT DBFLDP AS LIBRARY, DBFFDP AS FILE, 
	DBXTXT AS DESCRIPTION, 
	DBXATR AS FTYPE
FROM QSYS.QADBFDEP INNER JOIN QSYS.QADBXREF
	ON (DBFLDP=DBXLIB AND DBFFDP=DBXFIL)
WHERE DBFFIL = 'IVPMSTR' AND DBFLIB='HD1100PD'

This query selects the library of the dependent file, the file name, the text description of the file, and the type of file by joining QADBFDEP to QADBXREF on the dependent file name and library. The WHERE clause of the query causes the program to only list files that are dependent on IVPMSTR, in the library HD1100PD. The output of the query looks like this:


LIBRARY FILE DESCRIPTION FTYPE
HD1100BD IVLCMST1 IVPMSTR By Manufacturer Part Number LF
HD1100PD IMJWOBD2 By Line Buy ID SEL/OMIT - JOIN LF
HD1100PD IVLCMRTX By Manufacturer ID # omitting deleted items LF
HD1100PD IVLCMSTZ Lgl By Vendor Nbr & Item Vendor Manuf.Id# LF
HD1100PD IVLMMFL1 Multi-format by Item Number LF
HD1100PD IVLMSTRA By Counter Book S/G/C, Line Seq Number SEL/OMIT LF
HD1100PD IVLMSTRB By Purchasing Book S/G/C, Line Seq Nbr SEL/OMIT LF
HD1100PD IVLMSTRC By Product Number SEL/OMIT LF
HD1100PD IVLMSTRD By Counter Book S/G/C, Line Seq#, Item# SEL/OMIT LF

Note that, depending on the security on your iSeries, you may not be able to directly query the QXDBXREF or QADBFDEP files. If you have a problem, use one of the logical files built over these physicals by substituting QADBLDEP for the QADBFDEP file and QADBXATR for the QADBXREF.

For more information about the system catalogs, see the iSeries SQL reference in the iSeries Information Center or go to my Web site, at www.SQLThing.com.


Howard F. Arner, Jr., is the author of iSeries and AS/400 SQL at Work. Howard also designed SQLThing Enterprise Edition, a query program and stored procedure editor specifically for the AS/400's unique capabilities, and Import Expert 400, a program for quickly importing data from almost any data source to the iSeries. You can purchase a copy of Howard's book or learn more about his products at www.sqlthing.com. Send your SQL questions to harner@sqlthing.com.


Sponsored By
ADVANCED SYSTEMS CONCEPTS


WHAT IF


Creating Queries, Reports and Downloads
was Easy, Fast and Convenient
for ALL Users?


- - - Make it happen with SEQUEL ! - - -

Get a Free Trial today.

Read More



Editors: Howard Arner, Joe Hertvik, Ted Holt, David Morris,
Managing Editor: Shannon Pastore
Publisher and Advertising Director: Jenny Thomas
Advertising Sales Representative: Kim Reed
Contact the Editors: To contact anyone on the IT Jungle Team
Go to our contacts page and send us a message.


THIS ISSUE
SPONSORED BY:

Advanced Systems Concepts
Profound Logic Software


BACK ISSUES

TABLE OF
CONTENTS

Querying the System Catalog Like DSPFD

Exchange Data the Easy Way with Windows File Shares

Reader Feedback and Insights: Don't Do Things On-the-Fly



Copyright © 1996-2008 Guild Companies, Inc. All Rights Reserved.