RDB/VMS Relational Database Operator ERASE — VMS CDD+_4.1A
Erases records from a relation. Before using the ERASE statement,
you must start a READ_WRITE transaction and establish a record stream
using a context variable with a FOR statement or a START_STREAM
statement. You cannot erase records from a view that was formed with
a WITH, REDUCED, or CROSS clause.
Example:
RDO> START_TRANSACTION READ_WRITE RESERVING
cont> COLLEGES FOR EXCLUSIVE WRITE
RDO> FOR C IN COLLEGES
cont> ERASE C
cont> END_FOR
RDO> COMMIT
Additional information available:
Format
ERASE ────> context-var ───┬────────>───────┬──>
└──> on-error ───┘
context-var A temporary name specified in an RSE for name
recognition. You must define the context variable in a
START_STREAM statement or in a FOR loop. Request HELP
on RSE for more information.
on-error The ON ERROR clause, which specifies a host language
statement or Rdb/VMS data manipulation statement to be
performed if an Rdb/VMS error occurs. Request HELP on
ON_ERROR for more information.
Examples
Example 1 Assume you wish to erase all the records in the COLLEGES relation: RDO> START_TRANSACTION READ_WRITE RESERVING cont> COLLEGES FOR EXCLUSIVE WRITE RDO> FOR C IN COLLEGES ERASE C END-FOR RDO> PRINT COUNT OF C IN COLLEGES 0 RDO> COMMIT This statement uses the loop established by the FOR statement and erases all the records from the COLLEGES relation.