![HP NonStop SQL/MP Скачать руководство пользователя страница 88](http://html.mh-extra.com/html/hp/nonstop-sql-mp/nonstop-sql-mp_programming-manual_165149088.webp)
Data Retrieval and Modification
HP NonStop SQL/MP Programming Manual for C—429847-008
4-20
FETCH Statement
FETCH Statement
The FETCH statement positions the cursor at the next row of the result table and
transfers a value from each column in the row specified by the associated SELECT
statement to the corresponding host variable.
To run a FETCH statement, a process started by the program must have read access
to tables or views associated with the cursor. For information about process access,
see
Required Access Authority
on page 7-1.
NonStop SQL/MP returns these values to
sqlcode
after a FETCH statement.
The cursor must be open when the FETCH statement runs. The FETCH statement
must also run within the scope of all other SQL statements, including the DECLARE
CURSOR, OPEN, INSERT, DELETE, UPDATE, and CLOSE statements, that refer to
the cursor.
NonStop SQL/MP resets values in an SQLSA structure immediately before a FETCH
statement runs. If you use an SQLSA value elsewhere in your program, save the value
in a variable immediately after the FETCH statement runs. To monitor statistics for a
cursor, declare accumulator variables for the required values and add the SQLSA
values to the accumulator variables after each FETCH statement runs.
For audited tables and views, the FETCH statement must run within the same TMF
transaction as the OPEN statement for the cursor.
This FETCH statement retrieves information from the PARTS table:
EXEC SQL BEGIN DECLARE SECTION;
struct parts_type /* host variables */
{
short partnum;
char partdesc[19];
long price;
short qty_available
} parts_rec;
...
EXEC SQL END DECLARE SECTION;
...
...
EXEC SQL DECLARE list_by_partnum CURSOR FOR
SELECT partnum,partdesc,price,qty_available
FROM =parts
sqlcode
Value
Description
0
The FETCH statement was successful.
100
The end of a table was encountered.
<0
An error occurred;
sqlcode
contains the error number.
>0 (¦100)
A warning occurred;
sqlcode
contains the first warning number.
Содержание NonStop SQL/MP
Страница 4: ......
Страница 14: ...Contents HP NonStop SQL MP Programming Manual for C 429847 008 x ...
Страница 34: ...Introduction HP NonStop SQL MP Programming Manual for C 429847 008 1 8 SQL MP Version Management ...
Страница 60: ...Host Variables HP NonStop SQL MP Programming Manual for C 429847 008 2 26 VARCHAR Data Type ...
Страница 68: ...SQL MP Statements and Directives HP NonStop SQL MP Programming Manual for C 429847 008 3 8 Finding Information ...
Страница 156: ...Explicit Program Compilation HP NonStop SQL MP Programming Manual for C 429847 008 6 40 SQL Program Files ...
Страница 264: ...Dynamic SQL Operations HP NonStop SQL MP Programming Manual for C 429847 008 10 66 Detailed Dynamic SQL Program ...
Страница 294: ...SQL MP Sample Database HP NonStop SQL MP Programming Manual for C 429847 008 A 6 ...
Страница 300: ...Memory Considerations HP NonStop SQL MP Programming Manual for C 429847 008 B 6 Avoiding Memory Stack Overflows ...
Страница 304: ...Maximizing Local Autonomy HP NonStop SQL MP Programming Manual for C 429847 008 C 4 Skipping Unavailable Partitions ...