You are on page 1of 9

DB2/400

Data base files are of three types


1) physical files.
2) logical files.
3) field reference files.
4) flat file
Logical files are of two types.

1) Non-join logical files.(pfile keyword)


2) Join logical files.
Non-join logical files are of two types.

1) single record format non-join logical file.


2) Multi record format non-join logical file.

Join logical files are again of three types.

1) Natural join or inner join.


2) Left Outer join.(jdftval).
3) Self join.
1) PHYSICAL FILES
1)
PF1
0001.00
0002.00
0003.00
0004.00
0005.00
0006.00
0007.00
0008.00
r40009.00

UNIQUE
R PF1REC
ENAME
ENO
ESAL
EAGE
EBASIC
ESEX
EADD

20A
4S
4S
2S
4S
1A
50A

RANGE(1 1000)
VALUES(1000 3000 9000)
COMP(EQ 'M')
CHECK(ME)

0010.00
0011.00

EJD
K ENO

DATFMT(*DMY)

2)
PF90
0001.00
0002.00
0003.00
0004.00
0005.00
0006.00

UNIQUE
R PF90REC
ENAME
ESAL
EID
K EID

20A
4S
4S

3)
PF91
0001.00
0002.00
0003.00
0004.00
0005.00
0006.00
4)
PF100
0001.00
0002.00
0003.00

R PF91REC
EID
EDEPT
EAGE
K EID

A
A
A

UNIQUE
4S
4A
2S

R REC1
NAME1
ADDR

10A
20A

R REC2
NAME2
TELEPHONE

10A
8S

5)
PF101
0001.00
0002.00
0003.00
6)
PF10
0001.00
0002.00
0003.00
0004.00

R REC1
NBR
NAME
K NBR

3S 0
20A

R PFL
EMPNAME
EMPNUM
EMPAGE
EMPSAL
K EMPNAME

20A
3S
2S
6P 2

7)
PF3
0001.00
0001.01
0003.00
0004.00
0005.00
0006.00
0007.00

A
A
A
A
A
A

2) LOGICAL FILES
1) NON-JOIN LOGICAL FILES
A)

single record format non-join logical file.

LF1
0001.00
0002.00
0003.00
0004.00
0005.00

R LF1REC
ENAME
ENO
ESAL
K ENO

PFILE(PF1)

b) Multi record format Non-join logical file.


LF2
0001.00
0002.00
0003.00
0004.00
0005.00
0006.00
0007.00
0008.00

R LF1REC
ENO
ENAME
K ENO
R LF2REC
EDEPT
ENO
K ENO

PFILE(PF1)

PFILE(PF2)

2. JOIN LOGICAL FILES


2.1) ( natural join or inner join)
JLF1
0001.00
R JREC
0002.00
J
0003.00
0004.00
*DESCEND)
0005.00
NAME1
0006.00
ADDR
0007.00
TELEPHONE
b) JOIN LOGICAL FILES USING DUPLICATE SEQUENCE
( natural join or inner join)
LF3
0001.00
R LF3REC
0002.00
J
0003.00
0004.00
0005.00
ENO
0006.00
EDEPT
07.0
K ENO

JFILE(PF1 PF2)
JOIN(PF100 PF101)
JFLD(NAME1 NAME2)
JDUPSEQ(TELEPHONE

JFILE(PF1 PF2)
JOIN(PF1 PF2)
JFLD(ENO ENO)
JDUPSEQ(ENAME)
JREF(PF1)

2.2 ) JOIN LOGICAL FILES USING JDFTVAL.


( since the file level keyword jdftval is used , it is called as
join logical file).

left outer

LF4
0001.00
0002.00
0003.00
0004.00
0005.00
0006.00
0007.00

R LF4REC
J
EID
EDEPT
K EID

JDFTVAL
JFILE(PF90 PF91)
JOIN(PF90 PF91)
JFLD(EID EID)
JREF(PF91)

LF12
0001.00
0002.00
0003.00
0004.00
0005.00
0006.00
0007.00
08.0

R LF123REC
J
ENO
EDEPT
ESAL

JDFTVAL
JFILE(PF2 PF1)
JOIN(PF2 PF1)
JFLD(ENO ENO)
JREF(PF2)

K ENO

JLF2
0000.01
0002.00
0003.00
0004.00
0005.00
0006.00
0007.00
08.0

R JOINREC
J
NBR
NAME
SALARY

JDFTVAL
JFILE(PF10 PF11)
JOIN(PF10 PF11)
JFLD(NBR NBR)
JREF(PF10)

K NBR

2.3) DYNSLT ALONG WITH JDFTVAL (SELECT/ OMIT KEYWORDS)


LF1
0000.01
0001.00
0002.00
0003.00
0004.00
0004.01
0005.00
0006.00
0007.00
0008.00
0009.00
0010.00

A
A
A
A

R LREC1
J

A
A
A
A
A
A

EMPNUM
EMPNAME
EMPAGE
EMPSAL
K EMPNUM
O EMPNUM

2.4) Self Join


Sj1

pf

0001.00

R RCD1

DYNSLT
JDFTVAL
JFILE(PF3 PF4)
JOIN(PF3 PF4)
JFLD(EMPNUM EMPNUM)
JDUPSEQ(EMPAGE)
JREF(PF3)

COMP(LT 502)

0002.00
0003.00
0004.00
NBR
000001
000002
000003
000004
******

NBR
NAME
MGRNBR
NAME
MGRNBR
235
shankar
440
440
praveen
729
500
srinivas
440
729
srikanth
888
******** End of report

3S
10A
3S

DFT('NONE')

********

SJ3
LF (Self join Source Member)
0000.01
0002.00
A
R JOINREC
0003.00
A
J
0004.00
A
0005.00
A
NBR
0006.00
A
NAME
0007.00
A
MGRNAME
0008.00
A

JDFTVAL
JFILE(SJ1 SJ1)
JOIN(1 2)
JFLD(MGRNBR NBR)
JREF(1)
JREF(1)
RENAME(NAME)
JREF(2)

O/P:000001
000002
000003
000004

NBR
235
440
500
729

NAME
shankar
praveen
srinivas
srikanth

NAME
praveen
srikanth
praveen
NONE

3)

FIELD REFERENCE FILE

RF1 (data base file)


0002.00
0003.00
0004.00
0005.00
0006.00
0007.00

A
A
A
A
A
A

R RF1REC
EMPNUM
EMPNAME
EMPAGE
EMPSAL
EMPTELPNUM

3S
20A
2S
6P 2
7S

TEXT('EMPLOYEE NUMBER')

3.1) PR1 (field reference file)


0002.00
0003.00
0004.00
0005.00
0006.00
0007.01
0008.00

A
A
A
A
A
A
A

R PR1REC
EMPNUM
EMPNAME
EMPAGE
EMPSAL
K EMPNUM

REF(PVN/RF1)
R
R
R
R

3.2) PHYSICAL FILE USING REF KEYWORD.

PF2
0001.00
0002.00
d0003.00
0004.00
0005.00

R PF2REC
ENO
EDEPT
K ENO

REF(PF1)
TEXT('EMPLOYEE RECORD')

R
4A

3.3) LOGICAL FILE USING REFACCPTH KEYWORD.


0001.00
0002.00
R LFREC

REFACCPTH(PRA1/PF1)
PFILE(PF1)

BASIC COMMANDS

1)
2)
3)
4)
5)
6)
7)

To
To
To
To
To
To
To

Create a Library - CRTLIB <F4> (TYPE *TEST & *PROD)


Create a Source PF CRTSRCPF <F4>
Create a PF CRTPF < F4> or F6 option
Create a LF CRTLF <F4> or F6 option
Create a Field Reference File CRTPF <F4> ( MBR *NONE)
add a library to library list ADDLIBLE or EDTLIBL
enter data into a PF
STRDFU
UPDDTA
8) To retrieve data from a PF
RUNQRY *N <filename>
9) To add a member to a PF

Prerequisite: CHGPF <F4> Max members :- 1 change to any other


number
&
ADDPFM <F4>
10) To copy data from one object to another object
CPYF <F4>
11) To get detailed description of an object
DSPOBJD <F4> (Detail *Service)
WRKOBJ <F4> (Detail *Service)
12) To get the description of all fields of a PF
DSPFFD < F4>
13) To get all the Logical Files which are built over a PF
DSPDBR <F4>
14) To get all the PFs used by a LF
DSPFD <F4>
15) Use of DLTPCT parameter in a PF
16) Use of RGZPFM & REUSEDLT (*YES) commands
17) Use of REFACCPTH keyword
18) Use of FORMAT keyword
19) Use of MAINT parameter in a PF and types of access path maintenance

Immediate Access Path Maintenance


Delayed Access Path Maintenance

Rebuild Access Path Maintenance

===============================================================
FAQs related to DB2/400 part:What are Database files?
Database files are AS/400 objects that contain data or provide access to data.
What are Device files?
Device files contain no actual data, but gives introduction about how to use a
particular device.
Ex: - Printer File (PRTF), Display File (DSPF), Tape File (TAPF), Diskette
File (DKTF)
What are Save Files?
Save Files are of type *File and attrib *Save are a special form of files that
are used to save or restore data.
Ex: - Similar to Log Files in Windows.
What are DDM Files?
DDM files are AS/400 objects, which represent files that exist on a remote
machine
Important Points to be covered

1.
2.
3.
4.
5.
6.
7.
8.
9.

DSPFFD
DSPFD
DSPDBR
DSPOBJD with parameter Detail (*service)
WRKOBJ with parameter Detail (*service)
Access Path & Open Data Path
DSPPFM You can view the data that exists in a specific data member of
a file by using DSPPFM command.
Externally Described Files Data base files that are created with field
level description are referred to as Externally Described Files.
Program Described Files - Only the length of the record in the file is
described to the system, the system does not know about the fields in
the file. These database files are referred to as Program Described
Files.
Note: - by using RCDLEN parameter on CRTPF or CRTSRCPF.

DB2 Limitations:File name Max 10 Characters


Record Format Name Max 10 Characters

Field Name Max 10 Characters


In a file
Can 2 fields have same name?
Can Record Format & Member have same name?
FORMAT: - This keyword references another database file on AS/400 from
which all the fields will be shared.
DATFMT
*MDY *DMY *YMD *ISO
*JOB
*JUL *USA

types in AS/400
mmddyy
ddmmyy
yymmdd
yyyy-mm-dd
It will accept as the format of the system.
yyddd
mm/dd/yy

Data types in AS/400


There are
1. A 2. P
3. S
4. B
5. F
6. H
7. L
8. T
9. Z

9 data types in AS/400


Character
Packed Decimal
Zoned Decimal
Binary
Floating point
Hexadecimal
Date
Time
Time Stamp

How will you read or update the records of the file which are using Arrival
sequence access path?
Using RRN Relative Record Number.
Two Logical Files LF1 & LF2 are based on a Physical File PF1. The Unique
Keyword is specified for LF1. If you use LF2 to add a record to PF1, can
you add a record if it causes a duplicate key value in PF1?
No.
High Priority Questions:Can you update a data base file using Join Logical Files?
No, U can update a d/b file using Single Record Format Non Join Logical
File
Usage of DDS Keyword REFACCPTH with real time example - to be covered with
out fail
What is Level Check Error? Why does that occur and whats the logic behind
it?

Access path maintenance techniques


1 Immediate maintenance *immed ( Access paths used by referential
constraints real time scenario to be given frequently used access
paths)
2 Rebuild Maintenance
3 Delayed maintenance ( use when there are relatively few changes to
the access path while the file members are closed & reduce the system
overhead by reducing the number of access paths to be maintained
immediately)
10 To be covered individually with real time scenario
What are the prerequisites that need to be done before adding a member to PF?
When u create a PF and did not fill up Maint parameter, then by default which
access path will the system take & why with real time scenario
Difference between RGZPFM & REUSEDLT Disadvantage of REUSEDLT parameter over
RGZPFM, even though both do the same work why RGZPFM is used over REUSEDLT?
When did u use DYNSLT file level keyword in ur real time and pls explain it?
Above 3 years exp & Low priority questions
Non - Usage of UNIT parameter using real time scenario to be covered with
out fail
- We avoid using UNIT parameter since managing auxiliary storage is a
hazardous task
R+ (I*N)
R Starting record count 10,000
I No of records to add each time (increment) 1,000
N Number of times to add the increment 3

You might also like