can i use unique key in LF
Answers were Sorted based on User's Feedback
Answer / venkat
The format of this keyword is:
UNIQUE[(*INCNULL | *EXCNULL)]The parameter is optional. When specified, it determines whether null key values cause duplicates. *INCNULL is the default and indicates to include null values when determining duplicates. *EXCNULL, when specified, indicates to exclude null values when determining duplicates.
When a logical file based on a physical file has the UNIQUE keyword, the physical file member or members cannot have duplicate key values.
When you specify the UNIQUE keyword for a physical or logical file, you must specify the MAINT(*IMMED) parameter value on the Create Physical File (CRTPF) or Create Logical File (CRTLF) command that creates the file. This means that the access path is maintained immediately when changes are made.
If you do not specify the UNIQUE keyword, records with duplicate key values are sequenced in the order you specify. If you specify the FIFO keyword, they are sequenced in first-in first-out order. If you specify the LIFO keyword, they are sequenced in last-in first-out order. If you specify the FCFO keyword, they are sequenced in first-changed first-out order. If you do not specify FIFO, LIFO or FCFO, the order in which the records are sequenced is not guaranteed.
You cannot specify the UNIQUE keyword with the FIFO, LIFO, FCFO, or REFACCPTH keywords.
Example
The following example shows how to specify the UNIQUE keyword for a logical file.
|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
00010A*
00020A* SAMPLE LOGICAL FILE (CUSMSTL)
00030A*
00040A UNIQUE
00050A R CUSREC PFILE(CUSMSTP)
00060A TEXT('Logical File Master Record')
00070A CUST
00080A NAME
00090A ADDR
00100A K CUST
Is This Answer Correct ? | 1 Yes | 0 No |
Answer / ravi kumar
Hi,
Yes. When Pf doesn't contain duplicate records based on key value then we can use UNIQUE keyword in logical file. If pf contain Duplicate values then LF will not compile.
I have tried in this scenario
Is This Answer Correct ? | 1 Yes | 0 No |
How to create a login screen using a command instead of display file.... intention is to get a password field on a command..... how do you achieve this...
can anybody help me that what is the procedure of debugging the service program?
1. If there are two programs using same file and 2 users are using the file at the same time and what can be done to allow them both to access? 2. How can remove lock from the file for accessing it by both users?
Can AnyOne tell me how to read join logical file in rpg from starting to end?
this is rpg3 code W0RTN IFEQ @CN,002 what is the means @CN,002
in a cl pgm records are copied to a file in qtemp a pgm is called to delete records from the file in qtemp no of records in file in library qtemp is checked wat shud be the count of records let say it was 10 initially endpgm
There is a excel sheet having details of Old account number and new account number. I need to update these details in my AS400 files. i.e. all the records having old account number should be replaced with new account number. There can be 100 or 200 or 300 PFs...no fix files known. how can we do this?Solution should be performance oriented
write an RPG program to calculate the marks of 5 students (A,B, C, D, E)in 3 different subjects (eng, math, sci) an display on the screen
How can read PF in reverse order (end to start) in CL pgm..
check existence of one record without using chain or read?
How to print Superscript / Subscript from RPG400
what is data area and how it is used in rpg program ?