Академический Документы
Профессиональный Документы
Культура Документы
8-1
8-3
OL868105
8-4
OL868110
DB File Descriptions
Define record formats for physical and logical files
Single record format for physical files One or more record formats for logical files Coded on DDS at levels below (shown highest to lowest): Physical file File Record Field Key Logical file File Record Join Field Key Selection
OL868115
8-6
OL868120
8-7
OL868125
8-8
OL868130
DDS - PF/LF
A* A A A A A A A A A A A A
Copyright IBM Corp. 1996, 2000 8-10
R POLINE_FMT PONBR R ITMNBR R POLQTYOO R POLITMCOSTR POLDATREC R POLQTYREC R POLSTATUS R K PONBR K ITMNBR
A* A A A A A
POOPNLI_LF
8-11
OL868145
8-12
OL868150
File Operations
Input Files
Sequential READ SETLL / SETGT READE / READP / READPE Random CHAIN Output Files EXCEPT WRITE Update Files All Operations Above DELETE UPDATE Key Declaration KLIST / KFLD
OL868205
%Found(FileName) Record Found? %Open(FileName) File open? %Eof(FileName) EOF (or BOF) Reached?
8-15
OL868210
OL868215
8-18
OL868225
8-20
OL868235
Read with file name Read FileX If not %Eof : : EndIf Read with record format name Read Format2 If not %Eof : : EndIf
OL868240
E S
Disk 2
RecNo(Rrn) 0 Inz(0)
FFileY C C C C
OL868250
8-24
OL868255
SetLL FileX If %equal Read FileX If not %eof ** Process the record C EndIf C EndIf ** The LOVAL/HIVAL figurative constants can be used to ** position the file cursor for Keyed access C *LOVAL SetLL FileX C If %equal C :
OL868260
8-26
OL868265
FFileX IF E K Disk ** Chain with file name ** C Key Chain FileX C If %Found(FileX) C :
OL868270
is composed of (FLDA/FLDB/FLDC) KList KFld FldX KFld FldY KFld FldZ SetLL FileX If %equal Read FileXFmt If %Found(FileX) EndIf EndIf
OL868275
8-28
8-29
OL868280
FFileY IF E Disk ** ** Chain with file name ** C Rrn Chain FileY C If %Found(FileY) C :
OL868285
8-31
OL868290
8-32
OL868295
Key
FileX
OL8682A0
8-34
OL8682A5
READP / SETGT
FFileX IF E K Disk ** ** Set greater than pointer with file name ** C Key SetGT FileX ** Beginning of File? C DoW not %eof C ReadP FileX ** ** Process the record ** C EndDo
OL8682B0
8-36
OL8682B5
SETGT/READPE
FFileX IF E K Disk D Key S 5A D Msg S 15A ** C *Entry Plist C Parm Key C Key SetGt FileX ** No record key greater than Key argument. Last group encountered? C If not %Found(FileX) C Key Setll FileX ** C If %Found(FileX) ** Must be at last group - reposition to end of group again C Key SetGt Filex C Endif ** C Endif ** Read records backwards if group exists C If %Found(FileX) C Key ReadPE FileX ** Read group until beginning of group encountered (EOF). C Dow Not %Eof ** Process record C Eval Msg = Field1 + / + Field2 C Msg Dsply *REQUESTER C Key ReadPE FileX C Enddo ** C Endif C Eval *InLR = *ON
OL8682C0
8-37
UPDATE
FFileX UF ** DTotalSales ** ** C Key C C C C **
Copyright IBM Corp. 1996, 2000 8-38
E S
K Disk 5 0 INZ(0)
OL8682C5
8-40
OL8682D5
8-41
OL8682E0
ReadE (N) Vendor_PF If Not %Eof ReadP (N) Vendor_PF If Not %Eof ReadPE(N) Vendor_PF If Not %Eof Chain (N) Vendor_PF If %Found(Vendor_PF)
OL8682E5
OL8682F0
DELETE
FFileX UF E K Disk ** DTotalSales S 5 0 ** ** ** Delete current record based on CHAIN C Key Chain FileX ** C If %Found(FileX) C Delete FileX C EndIF
Copyright IBM Corp. 1996, 2000 8-45
OL8682G0
** Delete record using file key C Key Delete FileX C If Not %Found(FileX)
8-46
OL8682G5
8-47
OL8682H5
CRTPF/CHGPF Parameters
DLTPCT (*NONE) (deleted-records-threshold-%) ALWDLT* (*YES) (*NO ) (#recs incr. #incr)
SIZE
WAITFILE (*IMMED) (*CLS) (number-of-seconds) WAITRCD (*IMMED) (*NOMAX) (number-of-seconds) (*YES) (*NO )
ALWUPD*
(*YES) (*NO )
SHARE
* CRTPF only
OL868305
8-49
OL86810L
Unit Summary
Having completed this unit, you should be able to:
Describe the properties of a physical and logical file List and describe the RPG IV operation codes used for file handling Code RPG IV programs that read and update database files
OL863ZZZ