what is the difference between a physical and logical file on the as400

No replies
projex
projex's picture
Joined: Jan 17 2007
User offline. Last seen 6 hours 55 min ago.

i5/OS has a database which stores data in files. These are called physical files.

The Physical file stores the actual data.

The data is written to a physical file in arrival sequence. This data can be accessed by RRN (relative record number) where the first entry on the file (also known as a table) is relative record number 1. ie: the first record in the file. The next record is RRN=2 then RRN3 and so on.

If you want to access the data using a sequence of something on the file (for example CUSTOMER sequence) then you would design and create a logical view of this physical file specifying that you want it sequenced by customer.

The Logical File is a sequenced VIEW of the data in the Phsyical FIle.

Logicals can be used for updating, creating and deleting data within the physical that it is scoped over.

Join Logicals - are an advanced form of logical file selecting and sequencing data from more than one physical.


Wait - theres more

You can also add a KEY (the keyed sequence field used in a logical) to a physical file itself.

So a non-keyed FIFO Physical file definition might look like this

A R RECLIBTBL
A PRJCDE 3 COLHDG('PROJECT CODE')
A PRJDESC 50 COLHDG('DESCRIPTION')
A USRLIB 2750 COLHDG('USER LIBL')
A SYSLIB 165 COLHDG('SYSTEM LIBL')
A CURLIB 10 COLHDG('CURRENT LIBRARY')
A CHGUSER 10 COLHDG('LAST CHANGED BY')
A CHGDATE L COLHDG('LAST CHANGED ON')
A DATFMT(*ISO)
A CHGTIME T COLHDG('LAST CHANGED AT')

 

This same Phsyical file when defined to have a key sequence of the Project Code (PRJCDE) might look like this:

 

A   UNIQUE
A R RECLIBTBL
A   PRJCDE     3 COLHDG('PROJECT CODE')
A   PRJDESC   50 COLHDG('DESCRIPTION')
A   USRLIB  2750 COLHDG('USER LIBL')
A   SYSLIB   165 COLHDG('SYSTEM LIBL')
A   CURLIB    10 COLHDG('CURRENT LIBRARY')
A   CHGUSER   10 COLHDG('LAST CHANGED BY')
A   CHGDATE    L COLHDG('LAST CHANGED ON')
A   CHGTIME    T COLHDG('LAST CHANGED AT')
A K PRJCDE 
 

 

 

A logical over the same File sorting by Current Library (CURLIB) would look like this:

 

A R RECLIBTBL       PFILE(MODLIBTBL)
A K PRJCDE

 

 

 

 

 

 


Visitor Locations

Locations of visitors to this page

Recent comments

Who's online

There are currently 0 users and 7 guests online.

's beers

Beers are visible to logged in users only