Examples Of Delete - HP Neoview SQL Reference Manual

Hide thumbs Also See for Neoview SQL:
Table of Contents

Advertisement

DELETE WITH MULTI COMMIT FROM sales.orders
WHERE salesrep = 220 AND custnum <> 1234;
SET ON ROLLBACK Considerations
The SET ON ROLLBACK expression is evaluated when each row is processed during execution
of the DELETE statement. The results of the evaluation are applied when and if the transaction
is rolled back. Two important implications are:
If the SET ON ROLLBACK expression generates an error (for example, a divide by zero or
overflow error), the error is returned to the application when the DELETE operation executes,
regardless of whether the operation is rolled back.
If a DELETE operation is applied to a set of rows and an error is generated while executing
the DELETE operation, and the transaction is rolled back, the actions of the SET ON
ROLLBACK clause apply only to the rows that the DELETE operation processed before the
error was generated.
SET ON ROLLBACK Restrictions
The columns used in the SET ON ROLLBACK clause:
Must be declared as NOT NULL.
Cannot use the VARCHAR data type.
Cannot be used in the primary key or clustering key.

Examples of DELETE

Remove all rows from the JOB table:
DELETE FROM persnl.job;
--- 10 row(s) deleted.
Remove the row for TIM WALKER from the EMPLOYEE table:
DELETE FROM persnl.employee
WHERE first_name = 'TIM' AND last_name = 'WALKER';
--- 1 row(s) deleted.
Remove from the table ORDERS any orders placed with sales representative 220 by any
customer except customer number 1234:
DELETE FROM sales.orders
WHERE salesrep = 220 AND custnum <> 1234;
--- 2 row(s) deleted.
Remove all suppliers not in Texas from the table PARTSUPP:
DELETE FROM invent.partsupp
WHERE suppnum IN
(SELECT suppnum FROM samdbcat.invent.supplier
WHERE state <> 'TEXAS');
--- 41 row(s) deleted.
This statement achieves the same result:
DELETE FROM invent.partsupp
WHERE suppnum NOT IN
(SELECT suppnum FROM samdbcat.invent.supplier
WHERE state = 'TEXAS');
--- 41 row(s) deleted.
This is an example of a self-referencing DELETE statement, where the table from which
rows are deleted is scanned in a subquery:
DELETE Statement
111

Advertisement

Table of Contents
loading

Table of Contents