User Tools

Site Tools


duplicate_check_for_duplicate_key_entries_.htm
Navigation:  Language Reference > 13 - Built-in Functions >====== DUPLICATE (check for duplicate key entries) ====== Previous pageReturn to chapter overviewNext page
DUPLICATE( key )
file

blk2blue.jpg

DUPLICATE Checks duplicate entries in unique keys.
key The label of a KEY declaration.
file The label of a FILE declaration.

The DUPLICATE procedure returns a non-zero value (true) if writing the current record to the data file would post the “Creates Duplicate Key” error. With a key parameter, only the specified KEY is checked. With a file parameter, all KEYs declared without a DUP attribute are checked. DUPLICATE is most useful to detect potential duplicate key errors before writing to disk.

The DUPLICATE procedure assumes that the contents of the RECORD structure data buffer are duplicated at the current record pointer location. Therefore, when using DUPLICATE prior to ADDing a record, the record pointer should be cleared with: GET(file,0).

Return Data Type: LONG

Example:

IF Action = 'ADD' THEN GET(Vendor,0).            !If adding, clear the file pointer

IF DUPLICATE(Vendor)                             !If this vendor already exists

SCR:MESSAGE = 'Vendor Number already assigned'  !display message

SELECT(?)                                       !and stay on the field

END

See Also:

GET

ADD

DUP

duplicate_check_for_duplicate_key_entries_.htm.txt · Last modified: 2021/04/15 15:57 (external edit)