Create View and LF Non-Keyed in IBM i

Create View and LF Non-Keyed in IBM i
Create View and LF Non-Keyed in IBM i, CREATE VIEW, CRTLF , non keyed lf, logical file, view, as400,ibmi, db2, sql, db2 for i sql, dds to ddl, database modernization, dds to sql
Create View and LF Non-Keyed in IBM i

View and LF are applied to the existing tables to access their data more quickly and efficiently.

This article will cover the creation of the View and Non-key LF.

LF Non-Keyed

DDS File

A          R RDDS8                                                  
A            FLD1          10A         TEXT('FIRST TEXT FLD')       
A                                      COLHDG('FIRST' 'TEXT' 'FLD') 
A            FLD2           2P 0       TEXT('FIELD2')               
A                                      COLHDG('FIELD2')             
To create the LF on the above DDS file PFILE keyword with the file name is used at the record level.
A          R Record Formate                    PFILE(File Name)

Now, we will create the Non-Keyed LF on the above DDS file

Non-Keyed LF script

A          R RDDS8                     PFILE(DDS8) 
A            FLD1                                  
A            FLD2 

DSPFD on Non-keyed LF 



View

DDL Table

CREATE TABLE LONGNAMETABLEDDL11(                                        
  LONGNAMECOLUMN_FLD1 FOR COLUMN FLD1 CHAR(10) NOT NULL WITH DEFAULT,   
  LONGNAMECOLUMN_FLD2 FOR COLUMN FLD2 DECIMAL(2) NOT NULL WITH DEFAULT  
                  )                                                     
                  RCDFMT RDDS8;                                         
   LABEL ON LONGNAMETABLEDDL11(                                         
     FLD1 IS 'FIRST               TEXT                FLD',             
     FLD2 IS 'FIELD2'                                                   
                 );                                                     
   LABEL ON LONGNAMETABLEDDL11(                                         
     FLD1 TEXT IS 'FIRST TEXT FLD',                                     
     FLD2 TEXT IS 'FIELD2'                                              
                 );                                                     
                                                                        
   RENAME LONGNAMETABLEDDL11 TO SYSTEM NAME DDL11;                      
To create the View on the above DDL table Create View keyword is used.
CREATE VIEW Long Name AS Select Query RCDFMT Record Formate
Now, we will create the View on the above DDL table.

View script

CREATE VIEW LONGNAMEVIEWDDL11VW1 AS SELECT  FLD1,FLD2 FROM DDL11 RCDFMT RDDS8;      

RENAME LONGNAMEVIEWDDL11VW1 TO SYSTEM NAME DDL11VW1;        

DSPFD on View

Related Post

Post a Comment

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