Skip to main content


Deletes a record from a MultiValue file.


DELETE filevar,recID 
   [SETTING var] [LOCKED statements] [ON ERROR statements] [THEN statements] [ELSE statements]

DELETEU filevar,recID 
   [SETTING var] [LOCKED statements] [ON ERROR statements] [THEN statements] [ELSE statements]


filevar A local variable used as the file identifier of an open MultiValue file. This variable is set by the OPEN statement.
recID The record ID of the record to be deleted.
SETTING var Optional — When an error occurs, sets the local variable var to the operating system's error return code. Successful completion returns 0; error return codes are platform-specific. The SETTING clause is executed before the ON ERROR clause. Provided for jBASE compatibility.


The DELETE statement deletes a record from a MultiValue file. The DELETEU statement performs the same operation, but does not release an existing update lock if one was established.

You must use the OPEN statement to open a file before issuing either of these DELETE statements.

DELETE and DELETEU delete records without waiting for conflicting locks on those records to be released. To require that the program wait indefinitely for a conflicting lock to be released, you can check for locks prior to calling DELETE or DELETEU by using an IF RECORDLOCKED statement. For example:

IF RECORDLOCKED(filevar,recID) >= 0 THEN
     DELETE filevar,recID THEN ... ELSE ...
ELSE STOP 5010,@ACCOUNT,filevar,recID

Alternatively, you can set the $OPTION WRITE.LOCK.WAIT configuration option. However, this option applies globally, which can introduce unnecessary waits, such as on READ statements, and significantly slow down programs.

If lock contention is active, to specify the action that occurs when a record is locked, you can optionally specify a LOCKED clause.

You can optionally specify an ON ERROR clause. If record delete fails, the ON ERROR clause is executed. This may occur if the filevar file has already been closed.

You can optionally specify a THEN clause, an ELSE clause, or both a THEN and an ELSE clause. If the record delete is successful, the THEN clause is executed. If record delete is attempted but fails, the ELSE clause is executed.

DELETE completes successfully if the recID refers to a non-existent record.


The following example illustrates the use of the DELETE statement:

OPEN "Myfile.Test" TO myfile
DELETE myfile,myrec ON ERROR PRINT "no delete"

See Also

FeedbackOpens in a new tab