sapdev logo background
sapdev logo sapdev logo
Comments

ABAP OPEN CURSOR Statement syntax, information and example SAP source code



Return to Statement index



OPEN CURSOR

Short Reference

ABAP Syntax_2 OPEN CURSOR [WITH HOLD] dbcur FOR
SELECT result
FROM source
[[FOR ALL ENTRIES IN itab] WHERE
sql_cond ]
[GROUP BY group ] [HAVING group_cond ]
[ORDER BY sort_key ].

ABAP_ADDITION:
... WITH HOLD

What does it do? This statement opens a
database cursor for the selection defined after FOR , and associates a cursor variable dbcur with this database cursor. The result set of the selection can be read with the statement FETCH .
dbcur expects a declared variable with the specific predefined data type cursor . A database cursor dbcur that has already been opened cannot be opened again. A line of the result set is always assigned to an opened database cursor as a cursor position. After the OPEN CURSOR statement, the database cursor is positioned in front of the first line of the result set.
After FOR , the syntax of a SELECT statement can be entered which contains all the additions of the normal SELECT statement, except for INTO and APPENDING . In the addition result , the addition SINGLE also cannot be used after SELECT .
Only a limited number of database cursors can be open at the same time. An open database cursor can be closed using the statement CLOSE CURSOR . In addition, an open database cursor is closed for a database commit or a database rollback .
If a cursor variable dbcur of an open database cursor is assigned to another cursor variable or passed as a parameter, the latter is associated with the same database cursor at the same position. A cursor variable of an open database cursor can also be passed to procedures that have been called externally, to enable the database cursor to be accessed from there.
Latest notes: We do not recommend that you assign cursor variables to each other, but rather set them exclusively using the statements
OPEN CURSOR and CLOSE CURSOR .
If write accesses are made on a database table for which a database cursor is open, the results set is database-specific and undefined. Avoid this kind of parallel access if possible.

ABAP_ADDITION ... WITH HOLD

What does it do? If the addition WITH HOLD is specified, the database cursor is not closed by a database commit executed using Native SQL .
Latest notes: The addition WITH HOLD is ignored by implicit database commits , by commits produced by the statement COMMIT WORK , or by any rollbacks that always close the database cursor.
A Native SQL database commit can be performed using the DB_COMMIT function module, for example.
Wenn der Zusatz WITH HOLD angegeben ist, d�rfen in der INTO
-Klausel der Anweisung FETCH keine
LOB-Handle s erzeugt werden.
Documentation extract taken from SAP system, � Copyright SAP AG. All rights reserved




OPEN
OPEN_DATASET




comments powered by Disqus