Data Retrieval and Modification
HP NonStop SQL/MP Programming Manual for C—429847-008
4-24
CLOSE Statement
FROM sales.parts
WHERE (partnum >= :parts.partnum);
...
EXEC SQL OPEN get_by_partnum;
EXEC SQL FETCH get_by_partnum ... ;
... /* Test the value(s) in the current row. */
/* Delete the current row */
EXEC SQL DELETE FROM sales.parts
WHERE CURRENT OF get_by_partnum ;
... /* Branch back to FETCH the next row. */
EXEC SQL CLOSE get_by_partnum;
CLOSE Statement
The CLOSE statement closes an open SQL cursor. After the CLOSE statement runs,
the result table established by the OPEN statement no longer exists. To use the cursor
again, you must reopen it using an OPEN statement.
A program does not require special authorization to run a CLOSE statement.
A CLOSE statement must be within the scope of all other SQL statements, including
the DECLARE CURSOR, OPEN, FETCH, INSERT, DELETE, and UPDATE
statements, that refer to the cursor.
This CLOSE statement closes the
list_by_partnum
cursor:
...
void list_func(void)
{
...
EXEC SQL CLOSE list_by_partnum;
}
Only an explicit CLOSE statement (or a FREE RESOURCES statement) closes an
open SQL cursor. The CLOSE operation releases the resources used by the cursor
and frees any locks the cursor holds. If you are planning to reuse a cursor later in your
program, you can usually leave it open to save the overhead of opening it. However, if
your program is a Pathway server, always close an open cursor before returning
control to the requester, especially if the requester initiated a TMF transaction.
Using Foreign Cursors
Foreign cursors are cursors that are not declared in the program or procedure in which
they are referenced. Only dynamic cursors can be foreign cursors. Static cursors
cannot be foreign cursors.
Summary of Contents for NonStop SQL/MP
Page 4: ......
Page 14: ...Contents HP NonStop SQL MP Programming Manual for C 429847 008 x ...
Page 60: ...Host Variables HP NonStop SQL MP Programming Manual for C 429847 008 2 26 VARCHAR Data Type ...
Page 294: ...SQL MP Sample Database HP NonStop SQL MP Programming Manual for C 429847 008 A 6 ...