Non-Join Logical file in AS400

Non-Join Logical file in AS400
Non-Join Logical file in AS400,Non-Join Single format LF in IBM i AS400,Simple LF in IBMI AS400 based on Single PF,Non-Join single format LF or simple LF in IBM i AS400,as400 tutorial,non join lf in as400,#non join logical file in as400,#non join logical file in ibm i,lf in as400,non join lf,#join logical file in as400,join lf in ibmi,logical file in as400,join lf in as400,#logical file in as400,non join multiple format lf in as400,non-join single format lf/simple lf in ibmi as400,simple lf in ibmi as400,learn as400,as400 basic introduction,non join multiple format lf in ibmi,self join in sql db2,as400 and sql tricks,ibmi,Non-Join Single format LF in IBM i AS400,Simple LF in IBMI AS400 based on Single PF,Non-Join single format LF or simple LF in IBM i AS400,as400 tutorial,non join lf in as400,#non join logical file in as400,#non join logical file in ibm i,lf in as400,non join lf,#join logical file in as400,join lf in ibmi,logical file in as400,join lf in as400,#logical file in as400,non join multiple format lf in as400,non-join single format lf/simple lf in ibmi as400,simple lf in ibmi as400,learn as400,as400 basic introduction,non join multiple format lf in ibmi,self join in sql db2,as400 and sql tricks,ibmi
Non-Join Logical file in AS400

Introduction

Non-Join Logical files are created on single or multiple record formats from the same or multiple physical files. So basically, It's a simple logical file.

There are two types of Non-Join Logical files

  1. Single Record Format Logical File
  2. Multiple Record Format Logical File

Single Record Format Logical File

A logical file created over a single physical file is called a single record format logical file.

Example of Single Record Format Logical File

Let's create a physical file and then create a single record format logical file on that physical file.

  • DDS script for the physical file PF1

    
A          R FMT1                                  
A            ID            10A       
A            NAME          20A        
A            AGE            3P 0
A            ADDRESS       50A 

Create the PF1 using the CRTPF command

  • Create LF1 on the PF1 as below having key fields defined as below.

    
A          R FMT1                      PFILE(PF1) 
A          K ID
A          K AGE

PFILE keyword is used to refer to the Physical file. Either we can use PFILE(LIB1/PF1) or PFILE(PF1), here the Library name is optional to use with the PFILE keyword.

CRTLF command is used to create the Logical file. Make sure when you are creating the logical file. The library list must be set and contain the entry of the library in which PF resides. otherwise, your LF would not get compiled.

  • Create LF2 on the PF1 as below having UNIQUE key fields defined as below.

  
A                                      UNIQUE
A          R FMT1                      PFILE(PF1)                             
A          K ID
A          K AGE

  • Create LF3 on the PF1 as below having UNIQUE key fields defined and only Id, name, and age fields contained in it as below.

  
A                                      UNIQUE
A          R FMT1                      PFILE(PF1)    
A            ID            10A     
A            NAME          20A       
A            AGE            3P 0       
A          K ID

  • Create LF4 on the PF1 as below which same as PF1 as below.

  
A          R FMT1                      PFILE(PF1)         

Multiple Record Format Logical File

A logical file created over multiple record formats two or more physical files

Example of Multiple Record Format Logical File

Let's create two physical files and then create a multiple record format logical file on that physical file.

  • DDS script for the physical file PF1

    
A          R RMT1                                  
A            ID            10A       
A            NAME          20A        
A            AGE            3P 0
A            ADDRESS       50A 

Create the PF1 using the CRTPF command.

  • DDS script for the physical file PF2

    
A          R FMT2                                 
A            ID            10A
A            PHONE         10A 
A            STATUS         6A 

Create the PF2 using the CRTPF command.

  • Create multiple record format LF named LF1 on the PF1 and PF2 as below

    
A          R FMT1                      PFILE(PF1) 
A          K ID
A          R FMT2                      PFILE(PF2) 
A          K ID
A          K PHONE

As we can see this Logical file contains two record formats FMT1 and FMT2 from file PF1 and PF2 respectively and is referred to in LF using the PFILE keyword.

Create the LF using the CRTLF command.

Related Post

Post a Comment

© AS400 and SQL Tricks. All rights reserved. Developed by Jago Desain