Operations

Implicit within each event is an operation that is either insert, update, delete, upsert, or safedelete.

Each operation has an equivalent numeric code, and there are special constants insert, update, delete, upsert, and safedelete for these numeric values. The operation is set to insert when a record event is created.
Use the function getOpcode to get the operation out of an event, and setOpcode to set the operation. The function setOpcode alters the record event without making a copy. For instance, this prints the numeric codes for insert (which is 1) and safedelete (which is 13):
[ integer k; | string data;] v;
v := [k=9;|];
print('opcode=', string(getOpcode(v)), '\n');
setOpcode(v,safedelete);
print('opcode=', string(getOpcode(v)), '\n');

The operations within record events are used in streams and event caches. This is described in more detail in subsequent topics.