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

SQL/MX Statements
HP NonStop SQL/MX Release 3.2 Reference Manual691117-001
2-325
C Examples of UPDATE
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
INTO SQL DESCRIPTOR 'out_sqlda'
END-EXEC.
...
PERFORM UNTIL SQLSTATE NOT = SQLSTATE-OK
* Retrieve and test values in the descriptor area
...
EXEC SQL UPDATE CUSTOMER SET CREDIT = :new-default
WHERE CURRENT OF cursor1
END-EXEC.
EXEC SQL FETCH cursor1
INTO SQL DESCRIPTOR 'out_sqlda'
END-EXEC.
END-PERFORM.