Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Fetching data through Native SQL

Former Member
0 Likes
374

Hi,

What is the use of FETCH NEXT while fetching the data from the tables using Native SQL?

What is the error 923 in Native SQL?

Thanks & Regards,

Roja Velagapudi.

1 REPLY 1
Read only

Former Member
0 Likes
310

hi,

Basic form

FETCH NEXT CURSOR c target.

Effect

Uses the cursor c to read the next line or lines from the dataset of a database table determined by OPEN CURSOR . The cursor must be a variable of the type CURSOR and must be explicitly opened with OPEN CURSOR . To specify the target area into which you read the selected data, use INTO clause target .

FETCH belongs to the Open SQL command set.

After each execution of the FETCH statement, the system field SY-DBCNT contains the number of lines read so far.

The return code value is set as follows:

SY-SUBRC = 0 At least one line was read.

SY_SUBRC = 4 No line was read.

Example

Output the passenger list for the Lufthansa flight 0400 on 28-02.1995:



TABLES SBOOK.
DATA C TYPE CURSOR,
WA LIKE SBOOK.
OPEN CURSOR C FOR SELECT * FROM SBOOK
WHERE
CARRID = 'LH ' AND
CONNID = '0400' AND
FLDATE = '19950228'
ORDER BY PRIMARY KEY.

DO.
FETCH NEXT CURSOR C INTO WA.
IF SY-SUBRC <> 0.
CLOSE CURSOR C. EXIT.
ENDIF.
WRITE: / WA-BOOKID, WA-CUSTOMID, WA-CUSTTYPE,
WA-SMOKER, WA-LUGGWEIGHT, WA-WUNIT,
WA-INVOICE.
ENDDO.

Hope this help, Do reward.