Update Statement - HP NonStop SQL/MP Programming Manual

For c
Table of Contents

Advertisement

Data Retrieval and Modification
...
EXEC SQL OPEN get_name_address;
...
/* Set values for begin_code and end_code. */
EXEC SQL FETCH get_name_address
...
/* Process the row values. */
EXEC SQL CLOSE get_name_address;
}

UPDATE Statement

When used with a cursor, an UPDATE statement updates rows, one row at a time, in a
table or protection view. To identify the set of rows to update (or test), specify the FOR
UPDATE OF clause in the associated SELECT statement. Before you update each
row, you can test one or more column values. If you decide to update the row, specify
the WHERE CURRENT OF clause in the UPDATE statement.
To run an UPDATE statement, a process started by the program must have read and
write access to the table or view being updated. This process must also have read
access to tables or views specified in subqueries of the search condition. For
information about process access, see
Do not use a stand-alone UPDATE statement to update a row that has been retrieved
using a FETCH statement. A stand-alone UPDATE statement invalidates the cursor's
buffering for the table and can substantially degrade performance.
An UPDATE statement must be within the scope of all other SQL statements, including
the DECLARE CURSOR, OPEN, FETCH, INSERT, and CLOSE statements, that refer
to the cursor. For audited tables and views, the UPDATE statement must run within the
same TMF transaction as the OPEN and FETCH statements for the cursor.
This example uses the cursor get_by_partnum and host variables
new_partdesc, new_price, and new_qty to update the PARTS table:
EXEC SQL DECLARE get_by_partnum CURSOR FOR
SELECT parts.partnum,
FROM
WHERE (parts.partnum >= :parts.partnum )
STABLE ACCESS
FOR UPDATE OF parts.partdesc,
HP NonStop SQL/MP Programming Manual for C—429847-008
INTO
:customer_row.custname,
:customer_row.street,
:customer_row.city,
:customer_row.state
:customer_row.postcode;
parts.partdesc,
parts.price,
parts.qty_available
sales.parts
parts.price,
parts.qty_available;
Required Access Authority
4-22
UPDATE Statement
on page 7-1.

Advertisement

Table of Contents
loading

Table of Contents