SQL/MX 2.x Reference Manual (H06.04+)

SQL/MX Statements
HP NonStop SQL/MX Reference Manual540440-003
2-237
C Examples of UPDATE
VALUES (50, 'JERRY','HOWARD', 1000, 137000.00);
--- 1 row(s) inserted.
UPDATE persnl.dept
SET manager = 50
WHERE deptnum = 1000;
--- 1 row(s) updated.
COMMIT WORK;
--- SQL operation complete.
This transaction uses SERIALIZABLE access, which provides maximum data
consistency.
C Examples of UPDATE
Reset the credit rating to the default value for all of the customers in the
CUSTOMER table:
EXEC SQL UPDATE CUSTOMER SET CREDIT = DEFAULT;
Use a loop to fetch and update by using a cursor:
...
char SQLSTATE_OK[6]="00000"; /* variable declarations */
EXEC SQL BEGIN DECLARE SECTION;
char SQLSTATE[6];
...
EXEC SQL END DECLARE SECTION;
...
EXEC SQL FETCH cursor1 INTO SQL DESCRIPTOR 'out_sqlda';
while (strcmp(SQLSTATE, SQLSTATE_OK) == 0) {
... /* retrieve and test values in descriptor area */
EXEC SQL UPDATE CUSTOMER SET CREDIT = :new_default
WHERE CURRENT OF cursor1;
EXEC SQL FETCH cursor1 INTO SQL DESCRIPTOR 'out_sqlda';
}
...
COBOL Examples of UPDATE
Reset the credit rating to the default value for all of the customers in the
CUSTOMER table:
EXEC SQL UPDATE CUSTOMER SET CREDIT = DEFAULT END-EXEC.
Use a loop to fetch and update by using a cursor:
01 SQLSTATE-OK PIC X(5) VALUE "00000".
EXEC SQL BEGIN DECLARE SECTION END-EXEC.
01 SQLSTATE PIC X(5).
...
EXEC SQL END DECLARE SECTION END-EXEC.
...
EXEC SQL FETCH cursor1