Description
Deletes a row from a table.
Syntax
Delete [tablevar | Cursor cursorvar], key Then | Else statements
Parameters
The Delete statement has the following parameters.
Parameter | Description |
---|---|
tablevar | Created by a previous Open statement. |
cursorvar | If accessing a cursor, cursorvar contains a cursor variable, and is preceded with the keyword Cursor. Cursor variables are initialized with a Select...By statement. |
Then | The statement(s) following Then are executed if a record is deleted successfully. |
Else | The 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
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