Deleting a record from a file


Delete a record from a file


delete record_id [nrs = label] [ue = label] [traps = label]

Deletes the currently selected record from the file with which the buffer record_id is associated, and, if secondary indexes exist for this file, deletes the corresponding secondary index records.


The record buffer containing the record to be deleted. This is frequently, though not necessarily, the default record buffer that is automatically created for each file opened within a program. This default buffer bears the same name as the file’s file_id. However, record_id may also be an additional buffer declared for the file by means of the declaration !record , as follows:

!record record_id = file_id

As only one record can be selected from a given file at one time, it is not relevant which buffer actually contains the selected record.

[nrs = label]

Traps the condition where no record is currently selected in the buffer record_id. Control passes to the line indicated by label

A record is selected by successfully performing a read, find, next, prev or match on the file, which must be open in update or create mode.

If this condition is not trapped, the error message No record selected is output and control passes to the active menu, if any. If no menu is active the program exits.

In a !report section, an untrapped nrs condition causes the command to be ignored.

[ue = label]

This error can occur only when an ODBC database that does not support record locking is being used. If two ODBC clients read the same record from such a database for update and then attempt to write or delete the record, only the first succeeds. The ue trap allows this situation to be trapped in Sculptor and the second user notified that their update operation has failed. Control is passed to the line indicated by label.

If this error is untrapped, Sculptor displays the default error message:

Update refused - record updated by another user

See ODBC record locking for more details.

[traps = label]

General purpose trap clause that traps any condition not explicitly trapped, passing control to the line indicated by label. It has the lowest priority, and is only invoked if a trappable condition has not been more explicitly trapped.


  • If the file is closed Sculptor automatically opens it, using the mode in which it was last open (defaulting to the mode in the file declaration).

  • Deleted records cannot be recovered. Deletion is immediate and permanent.

  • The space released by deleted records is reserved for reuse when records are subsequently inserted into the file. Therefore deletion of records does not create more space elsewhere. If there have been substantial and permanent deletions of records from a file, then the kfcopy utility may be used to remove the space left by deleted records.

  • It is possible to find out the number of deleted records currently held in a file by using the kfcheck utility on the file, with the -d switch.

  • If an untrapped condition occurs in a !report section, the command is ignored.


!function DeleteRec() {
     tmp.Msg = "Deletion abandoned"

     prompt "OK to delete this record?" \
          button = "YES", \
          button = "NO", DEL_CAPTION

     delete Rec2 traps = IGNORE

     switch (sys.Traps) {
          case = 0:
               tmp.Msg = "Record deleted"
               tmp.Msg = "Error or no record selected"

     caption tmp.Msg


Keyed files

Accessing keyed files

Updating keyed files

Record buffers