SQL/MX 2.x Reference Manual (G06.24+, H06.03+)

SQL/MX Statements
HP NonStop SQL/MX Reference Manual523725-004
2-243
COBOL Examples of UPDATE
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 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.
Publish/Subscribe Examples of UPDATE
Suppose that these SQL/MP tables and index (and the metadata mappings) have been
created:
CREATE TABLE $db.dbtab.tab1 (a int NOT NULL, b int, c int);
CREATE TABLE $db.dbtab.tab2 (a int, b int, c int);
CREATE INDEX $db.dbtab.itab1 ON tab1(b, c);
CREATE SQLMP ALIAS cat.sch.tab1 $db.dbtab.tab1;
CREATE SQLMP ALIAS cat.sch.tab2 $db.dbtab.tab2;
This example shows the SET ON ROLLBACK clause:
SET SCHEMA cat.sch;
UPDATE tab1