SQL Programming Manual for Pascal

NonStop SQL Statements and Directives
HP NonStop SQL Programming Manual for Pascal528614-001
3-11
DELETE
WHERE (PARTDESC = :PARTS.PARTDESC)
STABLE ACCESS
FOR UPDATE OF PARTDESC, PRICE, QTY_AVAILABLE;
For more information on cursors, see SELECT on page 3-29.
DELETE
The DELETE statement deletes one or more rows from a table or protection view. The
number of rows deleted is determined by the WHERE clause. A DELETE statement
can delete:
A single row
A set of rows
A set of rows, one row at a time using a cursor (a mechanism for dealing with a set
of rows returned in sequence to a program)
In general, specifying a delete operation programmatically in a TAL program is the
same as specifying a delete operation using SQLCI commands.
The SQLCODE values that NonStop SQL returns after a DELETE statement are:
After a successful delete operation, the SQLCA structure contains the exact number of
rows deleted. After an error on a delete operation, the SQLCA contains an
approximate number of rows deleted. To obtain the contents of the SQLCA, use the
SQLCADISPLAY or SQLCATOBUFFER procedure.
DELETE and Access
To execute a DELETE statement, a program's process accessor ID (PAID) must have
read and write access to the table or view and any table or view in subqueries of the
search condition.
Single-Row Delete Operation
To delete a single row, you move a key value to a host variable and then use the host
variable in the WHERE clause of the DELETE statement. The following DELETE
Value Meaning
0 The DELETE statement was successful.
100 No rows were found on a search condition.
< 0 An error occurred; SQLCODE contains the error number.
> 0 (not 100) A warning occurred; SQLCODE contains the first warning number.