SQL/MX 3.2 Reference Manual (H06.25+, J06.14+)

SQL/MX Statements
HP NonStop SQL/MX Release 3.2 Reference Manual691117-001
2-321
MXCI Examples of UPDATE
Referential actions SET DEFAULT, SET NULL or SET CASCADE for ON UPDATE
or ON DELETE rules are not supported, SQL error 4386 is returned.
For more information on the errors, see the SQL/MX Messages Manual.
MXCI 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:
SET TRANSACTION
ISOLATION LEVEL SERIALIZABLE;
--- SQL operation complete.
BEGIN WORK;
--- SQL operation complete.
DELETE FROM persnl.employee
WHERE empnum = 23;
--- 1 row(s) deleted.