Nonstop Database, HiRDB Version 9 UAP Development Guide
Table retrieval results usually consist of multiple rows. A cursor is used by the UAP to retrieve rows one at a time from the entire set of retrieved rows.
This section explains how to retrieve data using a cursor and how to use the cursor to update a retrieved row.
For details about how to use a cursor, see 3.5 Use of a cursor.
When table retrieval results consist of multiple rows or when retrieving data dynamically after preprocessing the SQL statement with the PREPARE statement, a cursor is used to retrieve the individual rows.
When retrieval results consist of one or fewer rows, it is possible to use the single row SELECT statement for retrieval instead of a cursor.
For details about the PREPARE and single row SELECT statements, see the HiRDB Version 9 SQL Reference manual.
As an example of using a cursor to retrieve multiple rows, the UAP below retrieves product codes and unit prices from a stock table:
When multiple rows are retrieved, a cursor is used to update the rows one at a time.
Although the single row SELECT statement can be used to update a retrieval that consists of one row or less, use of a cursor results in better processing efficiency.
As an example of using a cursor to update rows one at a time, the UAP below reduces the unit price of each product in the stock table by 10% (multiplies by 0.9):
As an example of a retrieval that does not use a cursor, the UAP below makes a count of the items in the stock table and sets the results in an embedded variable.
All Rights Reserved. Copyright (C) 2011, Hitachi, Ltd.