guides:programming:programmers_reference_manual:delete_statement

Delete statement

Deletes a row from a table.

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

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.
/* 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
  • guides/programming/programmers_reference_manual/delete_statement.txt
  • Last modified: 2024/06/19 20:20
  • by 127.0.0.1