SQL/MX Programming Manual for C and COBOL (G06.24+, H06.03+)
Static Rowsets
HP NonStop SQL/MX Programming Manual for C and COBOL—523627-004
7-19
Deleting Rows by Using Rowset Arrays
hva_jobcode[2] = 300;
hva_jobcode[3] = 400;
hva_jobcode[4] = 500;
...
EXEC SQL UPDATE persnl.employee
SET salary = salary * :hv_inc
WHERE jobcode = :hva_jobcode;
...
EXEC SQL BEGIN DECLARE SECTION END-EXEC.
01 sqlstate pic x(5).
01 numrows pic 9(9) comp.
01 rs.
01 hva-multiplier pic 9(4) comp.
02 ROWSET[5] hvajobcode pic 9(4) comp.
02 ROWSET[5] hvainc pic 9(4)v99 comp.
EXEC SQL END DECLARE SECTION END-EXEC.
...
****Input the salary increment *****
****Populate the rowset in some way *****
Move 100 TO hvajobcode (1)
Move 200 TO hvajobcode (2)
Move 300 TO hvajobcode (3)
Move 400 TO hvajobcode (4)
Move 500 TO hvajobcode (5)
EXEC SQL UPDATE employee
SET salary = salary * :hvainc
WHERE jobcode = :hvajobcode
END-EXEC.
...
The number of updated rows is stored in the ROW_COUNT field of the statement
information in the diagnostics area. You can retrieve the value in the ROW_COUNT
field by using the GET DIAGNOSTICS statement.
Deleting Rows by Using Rowset Arrays
The searched DELETE statement deletes matching rows of a table or view. The
matching rows are determined by the evaluation of the search condition in the WHERE
clause of the DELETE statement. Multiple logical executions of the statement are
performed by using arrays of values in the WHERE clause.
Use this general syntax:
For complete syntax, see the DELETE statement in the SQL/MX Reference Manual.
DELETE FROM table-name
WHERE column = :hostvar-array
COBOL