Set On Rollback Considerations; Set On Rollback Restrictions; Examples Of Update - HP Neoview SQL Reference Manual

Hide thumbs Also See for Neoview SQL:
Table of Contents

Advertisement

More than one subquery is not allowed if multiple-column syntax is used.
UPDATE t SET (a,b)=(SELECT x,y FROM z), (c,d)=(SELECT x,y FROM a))
If a subquery is used, it must return at most one row.

SET ON ROLLBACK Considerations

The SET ON ROLLBACK expression is evaluated when each row is processed during execution
of the UPDATE statement. The results of the evaluation are applied when and if the transaction
is rolled back. This has two important implications:
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 UPDATE operation executes,
regardless of whether the operation is rolled back.
If an UPDATE operation is applied to a set of rows and an error is generated while executing
the UPDATE operation, and the transaction is rolled back, the actions of the SET ON
ROLLBACK clause apply only to the rows that were processed by the UPDATE operation
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 UPDATE

Update a single row of the ORDERS table that contains information about order number
200300 and change the delivery date:
UPDATE sales.orders
SET deliv_date = DATE '1998-05-02'
WHERE ordernum = 200300;
Update several rows of the CUSTOMER table:
UPDATE sales.customer
SET credit = 'A1'
WHERE custnum IN (21, 3333, 324);
Update all rows of the CUSTOMER table to the default credit 'C1':
UPDATE sales.customer
SET credit = 'C1';
Update the salary of each employee working for all departments located in Chicago:
UPDATE persnl.employee
SET salary = salary * 1.1
WHERE deptnum IN
(SELECT deptnum FROM persnl.dept
WHERE location = 'CHICAGO');
The subquery is evaluated for each row of the DEPT table and returns department numbers
for departments located in Chicago.
Suppose that you want to change the employee number of a manager of a department.
Because EMPNUM is a primary key of the EMPLOYEE table, you must delete the employee's
record and insert a record with the new number.
You must also update the DEPT table to change the MANAGER column to the employee's
new number. To ensure all your changes take place (or that none of them do), perform the
operation as a transaction:
UPDATE Statement
173

Advertisement

Table of Contents
loading

Table of Contents