SQL Programming Manual for TAL

NonStop SQL Statements and Directives
HP NonStop SQL Programming Manual for TAL527887-001
3-13
DELETE
:parts^rec.partdesc,
:parts^rec.price,
:parts^rec.qty^available;
END;
EXEC SQL CLOSE order_by_partdesc_cursor;
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)
To execute a DELETE statement, a TAL 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.
In general, specifying a delete operation programmatically in a TAL program is the
same as specifying a delete operation using SQLCI commands. With SQLCI, you
specify the new values in an DELETE statement, while in a program, you set one or
more host variables to the new values and then use the host variables in the DELETE
statement.
This table shows the SQLCODE values that NonStop SQL returns after a DELETE
statement:
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.
If you delete all rows from a table, the table still exists until it is deleted from the catalog
with a DROP TABLE statement.
SQLCODE Value Description
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.