EXEC SQL - PERFORMING
EXEC SQL PERFORMING subr.
SELECT ... INTO :wa1 :wa2 ...
SELECT statement can be specified as a Native SQL statement. The Native
SQL interface opens a cursor for the
SELECT statement and reads the appropriate
data, row by row. The
subr subroutine is called each time a row is read successfully.
subr subroutine must be defined in the same ABAP program and must not have a parameter interface.
If the host variables specified in the
INTO are global data objects of the ABAP program, they can
be evaluated in the subroutine. In the subroutine,
sy-dbcnt gets the number
of rows read so far and
sy-subrc is set to the value 0. After the
sy-dbcnt contains the total number of rows read so far and
sy-subrc is set to 4 since no more rows could be read using the implicit cursor. If an overflow
occurs because the number or rows is greater than 2,147,483,647,
sy-dbcnt is set to -1.
Implicit cursor processing using the
PERFORMINGaddition is obsolete and forbidden in classes, since methods of global classes do not have access to the global data and the subroutines of the calling ABAP program. Use explicit cursor processing instead.
Implicit cursor processing can be exited using the (obsolete) statement
EXIT FROM SQL.
Reads multiple rows from the database table SCARR and calls the subroutine
evaluate for each row read.
DATA wa TYPE spfli-carrid. EXEC SQL PERFORMING evaluate. SELECT carrid FROM spfli INTO :wa WHERE mandt = :sy-mandt ENDEXEC. FORM evaluate. WRITE / wa. ENDFORM.
Explicit cursor processing.
DATA wa TYPE spfli-carrid. EXEC SQL. OPEN CUR FOR SELECT carrid FROM spfli WHERE mandt = :sy-mandt ENDEXEC. DO. EXEC SQL. FETCH NEXT CUR INTO :wa ENDEXEC. IF sy-subrc <> 0. EXIT. ENDIF. WRITE / wa. ENDDO.