Join Logical Files


Join logical files are similar to simple logical files both in concept and in manipulation. However, record structure and update capability have some differences that are worth analyzing.

Record Structure in Join Logicals

Join logical files can combine fields from several physical files in a single record format. The system only requires that the physical files have equivalent fields in each file. The fields must also have equal values through which to join the two records.

For example, consider the following case. You have three files: COM (customer order master) shown in Table 20.1, COLI (customer order line items) shown in Table 20.2, and IM (item master) shown in Table 20.3.

Table 20.1: Fields in the COM (Customer Order Master) File.

COORD#

Customer order number

COCUST

Customer number

COPO#

Purchase order number

Table 20.2: Fields in the COLI (Customer Order Line Items) File.

LIORD#

Customer order number

LIITEM

Item number

LIQTY

Quantity ordered

Table 20.3: Fields in the IM (Item Master) File.

IMITEM

Item number

IMDESC

Description

IMCOST

Unit cost

Through a join logical, you can combine all fields into a single record format (a single file containing all the fields), because COM and COLI have the order number in common, and COLI and IM have the item number in common. The join logical would therefore have the fields as shown in Table 20.4:

Table 20.4: Fields from Three Different Files Together in a Joined Logical File.

JFORD#

Customer order number

JFCUST

Customer number

JFPO#

Purchase order numeber

JFITEM#

Item number

JFQTY

Quantity ordered

JFDESC

Description

JFCOST

Unit cost

All the information shown in Table 20.4 would be contained in a single join logical file. The next time you need to create a program to print a report based on these fields, you would have to process only one file, the join logical.

Updating Data

Join logicals cannot be used to update the data fields they have joined. Join logical files can only be used to read data. If you want to change the contents of any of the fields in the join logical files record, you must perform the update through the appropriate physical file.



IBM i5/iSeries Primer(c) Concepts and Techniques for Programmers, Administrators, and Sys[... ]ators
IBM i5/iSeries Primer(c) Concepts and Techniques for Programmers, Administrators, and Sys[... ]ators
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 245

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net