NonStop SQL/MP Reference Manual

Table Of Contents
NonStop SQL/MP Reference Manual142115
U-6
Examples—UPDATE
The SQLCA records the number of rows updated.
Examples—UPDATE
The following example updates a single row of the ORDERS table that contains
information about order number 200038 and changes the delivery date:
>> UPDATE SALES.ORDERS SET DELIV_DATE = 880522
+> WHERE ORDERNUM = 200038;
--- 1 row(s) updated.
The following example updates several rows of the CUSTOMER table:
>> UPDATE SALES.CUSTOMER SET CREDIT = "A1"
+> WHERE CUSTNUM IN (21, 3333, 324);
--- 3 row(s) updated.
The following example increases the salary of each employee working for a
department located in San Francisco. The subquery is evaluated for each row of the
DEPT table and returns department numbers for departments located in San
Francisco.
>> VOLUME $VOL1.PERSNL;
>> UPDATE EMPLOYEE SET SALARY = SALARY * 1.1
+> WHERE DEPTNUM IN (SELECT DEPTNUM FROM DEPT
+> WHERE LOCATION = "SAN FRANCISCO" );
Suppose you want to change an employee's number. The employee is the 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.
100 No rows satisfied the search condition
> 0 A warning was issued
< 0 An error occurred; the UPDATE did not
complete