Deletes a record from a relation or open stream.
1 – Examples
The following programs demonstrate the use of the ERASE statement to delete records from a relation. These programs: o Start a READ_WRITE transaction o Find the records in COLLEGES with the college code "PURD" o Delete those records from the COLLEGES relation
1.1 – C Example
#include <stdio.h> DATABASE PERS = FILENAME "PERSONNEL"; main() { READY PERS; START_TRANSACTION READ_WRITE; FOR C IN COLLEGES WITH C.COLLEGE_CODE = "PURD" ERASE C; END_FOR; ROLLBACK; FINISH; }
1.2 – Pascal Example
program erase_record (input,output); DATABASE PERS = FILENAME 'PERSONNEL'; begin READY PERS; START_TRANSACTION READ_WRITE; FOR C IN COLLEGES WITH C.COLLEGE_CODE = 'PURD' ERASE C; END_FOR; ROLLBACK; FINISH; end.
2 – Format
(B)0[m[4mERASE[m qqqq> context-var qqqwqq>qqqqqqqqqqqqqwqq> mqq> on-error qqqj
2.1 – Format arguments
context-var A context variable. A temporary name that you associate with a relation. You define a context variable in a relation clause. For more information see the entry on Context Variables. on-error The ON ERROR clause. Specifies host language statement(s) to be performed if an error occurs during the ERASE operation. For more information see the entry on ON ERROR.