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: 

Insert multiple records into tables using native sql

0 Kudos
698

Hello guys,

Please help. We are using ORACLE DATABASE as backend.

1. I am selecting multiple records from SAP tables and want to insert records using NATIVE SQL, How can I do that any sample code?

2. We have created tables directly in ORACLE therefore using NATIVE SQL. These tables are not part of the SAP instance.

Please help with sample code. Any help will be appreciated.

Thanks,

James

4 REPLIES 4

raymond_giuseppi
Active Contributor
0 Kudos
113

First read some documentation like Native SQL in help.sap.com, also

read  the Rules of Engagement.

Regards,

Raymond

0 Kudos
113

Thanks for the information.

Former Member
0 Kudos
113

Hi,

Plesae refer to the below link.Hope its helpful for u.

https://scn.sap.com/thread/1016531

Regards,

Santanu Mohapatra

Former Member
0 Kudos
113

Hi Jim,

General way inserting data using Native SQL is

EXEC SQL.

  INSERT INTO <TABLENAME> (<FIELD1>, <FIELD2>, <FIELD3>)

         VALUES (<VALUE1>,<VALUE3><VALUE3>)

ENDEXEC.

Since in your case there is a internal table we require to loop at the table into work area, and the content of the work area is passed to the value.

LOOP it_tab1 into wa_itab1.

INSERT INTO <TABLENAME> (<FIELD1>, <FIELD2>,....<FIELDN>)

          VALUES (:wa_itab1-field1,:wa_itab1-field2,.....:wa_itab1-fieldN)

ENDEXEC.

ENDLOOP.

Also refer to below link

http://scn.sap.com/message/14176983#14176983