File Management operations overview

File management supports many operations that high-level language programs can use to process data. These include the following, which are grouped by category:

The operations listed above have certain restrictions based on file type and language support. For example, a program may not write to a file that has been opened for read only. Similarly, a read-by-key may not be issued for an ICF file. Since file overrides can occur during processing, an operation may not be allowed for the type of file that is ultimately being processed. See "Using overrides", for additional information.

Table 1 lists the file types and the main operations that are allowed. There are additional functions supported for some file types that are accomplished by additional operations or changes to these operations. For information on these additional functions and how the operations given here apply to display, tape, and diskette files, refer to either the Application Display Programming, SC41-5715-00 book or the Tape and Diskette Device Programming, SC41-5716-01 book. For equivalent information for database, ICF, DDM, printer, and save files, refer to the 5701 book, the 5442 book, the 5307 book, the 5713 book, and the 5304 book, respectively.

Table 2 and Table 3 map the OS/400-supported operations given in Table 1 to the high-level language operations (BASIC, ILE C, ILE COBOL, PASCAL, PL/I, and ILE RPG programming languages) supported on the system. For additional information on each operation and how it correlates to the file declaration in the program, see the appropriate language information. Note that not all OS/400 operations are supported in all languages.

Table 1. File Types and Their Main Operations
Operation File Types
Database Diskette Tape Printer Display ICF DDM Save
OPEN







Read X X X - X X X X
Write X X X X X X X X
Update X - - - X1 - X -
Delete X - - - X1 - X -
       




READ







By relative record number X - - - X1 - X -
By key X - - - - - X -
Sequential X X X - X X X X
Previous X - X - - - X -
Next X X X - X X X X
Invited







Device - - - - X X - -
       




WRITE-READ - - - - X X - -
       




WRITE







By relative record number X - - - X1 - X -
By key X - - - - - X -
Sequential X X X X X X X X
       




FEOD X X X X - - X X
       




UPDATE







By relative record number X - - - X1 - X -
By key X - - - - - X -
DELETE







By relative record number X - - - - - X -
By key X - - - - - X -
       




ACQUIRE - - - - X X - -
       




RELEASE - - - - X X - -
       




COMMIT X - - - - - - -
       




ROLLBACK X - - - - - - -
       




CLOSE X X X X X X X X
Note:

1
Operation allowed only for subfile record formats

Table 2. High-Level Languages and Their OS/400 Operations
Operation High-Level Languages
BASIC ILE C/400 Programming Language ILE COBOL/400 Programming Language
OPEN      
Read OPEN INPUT fopen, _Ropen OPEN INPUT
Write OPEN OUTPUT fopen, _Ropen OPEN OUTPUT, OPEN EXTEND
Update OPEN OUTIN fopen, _Ropen OPEN I-O
Delete OPEN OUTIN fopen, _Ropen OPEN I-O
       
READ


By relative record number READ REC _Rreadd READ
By key READ KEY _Rreadk, _Rformat READ KEY
Sequential READ NEXT, GET fread, fgetc, fgets, _Rreadf, _Rreadl, _Rreadn, _Rreadp, _Rreads, _Rformat, _Rpgmdev READ
Previous READ PRIOR _Rreadp READ
Next READ NXT, GET fread, _Rreadn READ, READ NEXT
Invited Device   _Rreadindv READ
       
WRITE-READ   _Rwriterd, _Rformat, _Rpgmdev  
       
WRITE


By relative record number WRITE REC _Rwrited WRITE
By key WRITE _Rwrite, _Rformat
Sequential WRITE fwrite, fputc, fputs, _Rwrite, _Rformat, _Rpgmdev WRITE
       
FEOD   _Rfeod  
       
UPDATE      
By relative record number REWRITE REC _Rupdate REWRITE
By key REWRITE KEY _Rupdate REWRITE
       
DELETE      
By relative record number DELETE REC _Rdelete DELETE
By key DELETE KEY _Rdelete DELETE
       
ACQUIRE   _Racquire ACQUIRE
       
RELEASE   _Rrelease DROP
       
COMMIT   _Rcommit COMMIT
       
ROLLBACK     ROLLBACK
       
CLOSE CLOSE, END fclose, _Rclose CLOSE, STOP RUN, CANCEL

Table 3. High-Level Languages and Their OS/400 Operations
Operation High-Level Languages
PASCAL PL/I ILE RPG/400 Programming Language
OPEN






Read RESET, GET, READ, READLN OPEN INPUT OPEN
Write REWRITE, WRITE, WRITELN OPEN OUTPUT OPEN
Update UPDATE OPEN UPDATE OPEN
Delete UPDATE OPEN UPDATE OPEN
       
READ      
By relative record number GET, READ READ KEY READ, CHAIN
By key   READ KEY READ, READE, CHAIN
Sequential GET, READ, READLN READ NEXT, GET READ
Previous GET, READ, READLN READ PRV READP, READPE
Next GET, READ, READLN READ NXT, GET READ, READE
Invited Device     READ
       
WRITE-READ     EXFMT
       
WRITE      
By relative record number PUT, WRITE, WRITELN WRITE, EXCPT primary file WRITE
By key   WRITE KEY WRITE, EXCEPT
Sequential PUT, WRITE, WRITELN WRITE, PUT WRITE, EXCEPT
       
FEOD     FEOD
       
UPDATE      
By relative record number PUT, WRITE, WRITELN REWRITE KEY UPDATE
By key   REWRITE KEY UPDATE
       
DELETE      
By relative record number   DELETE DELETE
By key   DELETE KEY DELETE
       
ACQUIRE     ACQ
       
RELEASE     REL
       
COMMIT use CL COMMIT PLICOMMIT subroutine COMMIT
       
ROLLBACK use CL ROLLBACK PLIROLLBACK subroutine ROLBK
       
CLOSE CLOSE, END CLOSE, STOP CLOSE, RETURN


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]