Application Development 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: 

Native SQL and FOR ALL ENTRIES statement

stefan_kolev4
Participant
0 Kudos

Hi,

I need to retrieve all records from external Oracle database using Native SQL for all records in an internal table in my program.

How can I do that ?

Cheers,

Stefan

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi

The first problem is to know if both db are linked by a dblink for example, then you can use the oracle native sql in your program see the help for EXEC SQL/ENDEXEC

But I don't think the option FOR ALL ENTRIES is supported by native sql: here you need to do a symple SELECT and load your internal table

Max

6 REPLIES 6

Former Member
0 Kudos

Hi

The first problem is to know if both db are linked by a dblink for example, then you can use the oracle native sql in your program see the help for EXEC SQL/ENDEXEC

But I don't think the option FOR ALL ENTRIES is supported by native sql: here you need to do a symple SELECT and load your internal table

Max

0 Kudos

Hi,

Thanls for your fast responce.

Imagine we have an internal table in our program and we want to retrieve all equal records from external db using native sql.

Should I insert all records in an internal table and then use read table statement ?

Stefan

0 Kudos

Should I insert all records in an internal table and then use read table statement ?

That depends on how you need to arrange your program, I can't understand what " all equal records" means

Max

0 Kudos

I am trying to do the same as SELECT....FOR ALL ENTRIES, but in Native SQL.

Stefan

0 Kudos

Hi

That mean you have an internal table with data from SAP and you need to load the data from extranal db in according to them?

If it's so I don't believe FOR ALL ENTRIES is supported and I don't know if there's a command like that, I think you have to upload record by record:

LOOP AT ITAB.
   EXEC SQL.
       SELECT * INTO :WA
            FROM <TABLE>
                  WHERE <FIELD> = :WA-FIELD.
     ENDEXC.
    IF SY-SUBRC = 0.
      APPEND WA TO ITAB2.
    ENDIF.
ENDLOOP.

mAX

0 Kudos

Hi Max,

     Thanks for your reply.

I have one different requirement like can we load data from external DB based on internal table field condiition


LOOP AT ITAB.

   EXEC SQL.

       SELECT * INTO :WA

            FROM <TABLE>

                  WHERE <FIELD> = :WA-FIELD AND <FIELD1> = ITAB-FIELD1.

     ENDEXC.

    IF SY-SUBRC = 0.

      APPEND WA TO ITAB2.

    ENDIF.

ENDLOOP.

Please see the underlined where clause and suggest accordingly.

Thanks in advance.

-- MRM