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

PL/SQL

Former Member
0 Likes
470

Hi all,

I am trying to retrieve a group of data using native sql stmts ( sellect stmnt) <> Exec sql and EndExcec .But wat happens is dat only first data gets fetched. Do i have run in it within a loop or add any other coding to retrive a group of data.

Thanks,

Kavitha

1 ACCEPTED SOLUTION
Read only

GrahamRobbo
SAP Mentor
SAP Mentor
0 Likes
450

Hi Kav,

try using a cursor. This code snippet if from the SAP Help for Native SQL.

DATA: F1(3), F2(3), F3(3). 
F3 = ' 1 '. 
EXEC SQL. 
  OPEN C FOR 
    SELECT CLIENT, ARG1 FROM AVERI_CLNT 
        WHERE ARG2 = :F3 
ENDEXEC. 
DO. 
  EXEC SQL. 
    FETCH NEXT C INTO :F1, :F2 
  ENDEXEC. 
  IF SY-SUBRC <> 0. 
    EXIT. 
  ENDIF. 
  WRITE: / F1, F2. 
ENDDO. 
EXEC SQL. 
  CLOSE C 
ENDEXEC.

Cheers

Graham

3 REPLIES 3
Read only

Former Member
0 Likes
450

Hi Kavitha,

I think you have to use DO..ENDDO (Loops)

Regards,

Atish

Read only

GrahamRobbo
SAP Mentor
SAP Mentor
0 Likes
451

Hi Kav,

try using a cursor. This code snippet if from the SAP Help for Native SQL.

DATA: F1(3), F2(3), F3(3). 
F3 = ' 1 '. 
EXEC SQL. 
  OPEN C FOR 
    SELECT CLIENT, ARG1 FROM AVERI_CLNT 
        WHERE ARG2 = :F3 
ENDEXEC. 
DO. 
  EXEC SQL. 
    FETCH NEXT C INTO :F1, :F2 
  ENDEXEC. 
  IF SY-SUBRC <> 0. 
    EXIT. 
  ENDIF. 
  WRITE: / F1, F2. 
ENDDO. 
EXEC SQL. 
  CLOSE C 
ENDEXEC.

Cheers

Graham

Read only

0 Likes
450

Have a look at the answers to your other PL/SWL posting in Data Transfers too: