SQL/MX 2.x Reference Manual (H06.10+, J06.03+)
Embedded-Only SQL/MX Statements
HP NonStop SQL/MX Reference Manual—544517-008
3-42
Considerations for FETCH
:variable-name
is a variable specification—a host variable. A variable name begins with a
colon (:).
Considerations for FETCH
Authorization Requirements
FETCH requires read access to any tables or views associated with the cursor or
iterator. Updating fetched rows requires write access to the table or view.
Ordering Fetched Rows
Successive executions of FETCH retrieve successive rows in the result table of the
cursor specification or iterator.
To control the order in which the rows appear, include an ORDER BY clause in the
cursor specification part of DECLARE CURSOR or in the prepared statement in the
case of a dynamic cursor.
To control the order in which the rows appear, include an ORDER BY clause in the
SELECT statement that is bound to the iterator.
Too Many Values or Too Many Variables
If the number of host variables is different from the number of columns in the result
table, the execution of FETCH raises an error condition.
Using Extended Dynamic Cursors
The name of an extended dynamic cursor is not known until run time. When FETCH
executes, the name must identify an open cursor within the same scope.
Status Information
You must declare the variables SQLSTATE or SQLCODE in your module or
compilation unit. For more information on declaring SQLCODE and SQLSTATE, see
the SQL/MX Programming Manual for C and COBOL.
FETCH returns a five-character status code to SQLSTATE, whose values include:
For more information on the ANSI SQL:1999 SQLSTATE class and subclass values,
see the SQL/MX Programming Manual for C and COBOL.
00000 The FETCH was successful.
02000 The result table is empty or the end of the table was encountered.
22xxx Data exception condition.
C/COBO
L
Java
C/COBO
L
C/COBO
L










