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

Query in native SQl

Former Member
0 Likes
547

I'm new to Native SQL commands.

Can somebody tell me how to fine tune this code.

Is there anything like FOR ALL ENTRIES in these commands also. We're using Oracle database.

loop at it_cus1.

EXEC SQL PERFORMING APPEND_IT_CUS2.

SELECT SAP_MASTNR, ANK_MASTNR

INTO

:IT_CUS2-KUNNR, :IT_CUS2-DATLT

FROM NOVARTIS.TABLE_ADRESS@ANKD

WHERE ANK_MASTNR = :IT_CUS1-DATLT

ENDEXEC.

endloop.

FORM append_it_cus2 .

APPEND it_cus2.

CLEAR it_cus2.

ENDFORM.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
510
Hi Phani

   Not sure but have you tried using subquery if you are
 extracting it_cus1 using native sql.

Kind Regards
Eswar
4 REPLIES 4
Read only

Former Member
0 Likes
511
Hi Phani

   Not sure but have you tried using subquery if you are
 extracting it_cus1 using native sql.

Kind Regards
Eswar
Read only

Former Member
0 Likes
510

Hi Eswar problem is I'm getting this it_cus1 using Open SQL.

Read only

former_member186741
Active Contributor
0 Likes
510

DOES THE DATABASE HAVE AKEY OR INDEX ON 'ANK_MASTNR' ... if not it will be slow.

Read only

0 Likes
510

you could try cursor processing, it might be more efficient:

EXEC SQL.

OPEN C FOR

SELECT SAP_MASTNR, ANK_MASTNR

FROM NOVARTIS.TABLE_ADRESS@ANKD

WHERE ANK_MASTNR = :IT_CUS1-DATLT

ENDEXEC.

loop at it_cus1.

EXEC SQL.

FETCH NEXT C into

:IT_CUS2-KUNNR, :IT_CUS2-DATLT

ENDEXEC.

APPEND it_cus2.

CLEAR it_cus2.

ENDloop.

EXEC SQL.

CLOSE C

ENDEXEC.