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
455

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

Former Member
0 Likes
421

Have a look at:

<a href="http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3b8b358411d1829f0000e829fbfe/content.htm">http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3b8b358411d1829f0000e829fbfe/content.htm</a>

where it explains how you can use a couple of methods to loop through the select.

2 REPLIES 2
Read only

Former Member
0 Likes
422

Have a look at:

<a href="http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3b8b358411d1829f0000e829fbfe/content.htm">http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3b8b358411d1829f0000e829fbfe/content.htm</a>

where it explains how you can use a couple of methods to loop through the select.

Read only

Former Member
0 Likes
421

Kavitha,

Check this sample code... may be helpful for you

DATA: BEGIN OF wa,

c_locid(3),

c_locname(50),

c_locstate(5),

END OF wa.

EXEC SQL.

CONNECT TO 'RAJ' AS 'V'

ENDEXEC.

EXEC SQL.

SET CONNECTION 'V'

ENDEXEC.

*- Get the data from MS-SQL Server

EXEC SQL.

open C1 for

select

loc_id,

loc_name,

loc_state

from ho_loc_mast

ENDEXEC.

DO.

EXEC SQL.

FETCH NEXT C1 into :wa-c_locid, :wa-c_locname, :wa-c_locstate

ENDEXEC.

IF sy-subrc = 0.

PERFORM loop_output.

ELSE.

EXIT.

ENDIF.

ENDDO.

EXEC SQL.

CLOSE C1

ENDEXEC.

ENDFUNCTION.

&----


*& Form LOOP_OUTPUT

&----


  • Output

----


FORM loop_output .

WRITE: /5 wa-c_locid, 10 wa-c_locname, 65 wa-c_locstate.

CLEAR wa.

ENDFORM. " LOOP_OUTPUT

~~Guduri