Description

Deletes a row from a table.

Syntax

Delete [tablevar | Cursor cursorvar], key Then | Else statements

Parameters

The Delete statement has the following parameters.

ParameterDescription
tablevarCreated by a previous Open statement.
cursorvarIf accessing a cursor, cursorvar contains a cursor variable, and is preceded with the keyword Cursor. Cursor variables are initialized with a Select...By statement.
ThenThe statement(s) following Then are executed if a record is deleted successfully.
ElseThe statement(s) following Else are executed if the deletion fails. The Status() function indicates the severity of the error, and the system variable @FILE_ERROR contains detail about the nature of the error.

See also

IfOpenSelect...By

Example

/* This code fragment selects the table and reads each row. 
If the fifth column of any row is the string "INACTIVE", then the row is deleted from the table. */
 
$Insert Logical
open "CUSTOMER" to CUST_FILE then
select CUST_FILE
done = FALSE$
loop
  readnext @ID Else Done = TRUE$
until done
  read CUST_REC from CUST_FILE, @ID then
   if CUST_REC<5> = "INACTIVE" then
    delete CUST_FILE, @ID else
     GoSub delete_error
    end
   end
  end else
   GoSub Read_Error
  end
repeat
end else
GoSub Open_Error
end
  • No labels