Skip to content

DELETE

FUNCTION

This command deletes data records from a file. Any secondary key or text field data associated with the deleted records is also deleted.

SYNTAX

DELETE link-name [USING KEY IS string-value]
[MISSING KEY PROCESS IS procedure]
[BUSY PROCESS IS procedure]
[ERROR PROCESS IS procedure]
[PROCESSING [IS] procedure]
DELETE link-name USING RECORD NUMBER IS numeric-value
[BUSY PROCESS IS procedure]
[RETRY IS retry-code-string]
[ERROR PROCESS IS procedure]
[PROCESSING [IS] procedure]
retry-code-string
C Continue with next command
I Ignore. Invalid for DELETE command.
N Do END PROCESS, continue with next command
S Skip busy record
Y Use standard busy processing
link-name
the link where the data file is specified.
string-value
a string data-name, variable, constant, or expression that specifies the primary key for the record.
procedure
the name of a procedure to perform.
numeric-value
a numeric data-name, variable, constant, or expression that specifies a record number from 0 to the file size minus 1.
retry-code-string
specifies the action to take if the command needs to be retried.

NOTES

  • Links must be declared and opened prior to any file input or output procedures.

  • The USING KEY clause is the default.

  • If the specified key is not in the data file, the MISSING KEY procedure is performed; if the
    MISSING KEY procedure is not specified, script execution continues with the next command.

  • A busy record condition occurs if the record being accessed is in use and locked by another user. The CHANGE and DELETE commands lock a record.

    By default, if the DELETE command specifies a record that is busy, the BUSY procedure is performed and, after five seconds, the command is retried. You can change this behavior by specifying a value for the WAIT-TIME Script-IV variable or by specifying a value for the PRM WAITLOCK statement. For more information on the PRM WAITLOCK statement see the Thoroughbred Basic Customization and Tuning Guide.

    Even if the BUSY procedure is not specified, script execution continues to wait until the record is available. The operator can press the Escape key to force script execution to continue, depending on the escape processing set for the script.

  • The BUSY PROCESS IS procedure is executed before the RETRY option is evaluated.

  • If an error occurs, other than a missing key or busy record, during the processing of this command, the ERROR procedure is performed. If ERROR is not specified, script execution continues with the next command.

  • Any secondary key or text field data associated with the deleted records is also deleted.

  • The string-value does not have to be a data name; however, an error occurs if the value is larger than the defined key and the command will terminate or the ERROR procedure will be performed. If you specify a value that is smaller than the defined key, the MISSING KEY procedure is performed and script execution continues with the next command.

  • The processing procedure will be executed AFTER the DELETE.

  • The processing procedure will not be executed if an error occurs.

EXAMPLES

IF TERM-KEY <> 4 THEN
DELETE 4SCUST USING KEY CUST-CODE
ENDIF
IF TERM-KEY <> 4 THEN
DELETE 4SCUST USING CUST-CODE
MISSING KEY PROCESS IS 21-IGNORE
LET INPUT-FLAG = "N"
ENDIF

SEE ALSO

ADD, CHANGE, KEY-NAME, RETRY. For information on the PRM WAITLOCK statement, please refer to the Thoroughbred Basic Customization and Tuning Guide.

From the Script-IV Language Reference, version 8.9.1. Open this page in the PDF