cancel
Showing results for 
Search instead for 
Did you mean: 

Error with Exec SQL in SAP ABAP

former_member717145
Discoverer
0 Kudos
475

Hi All,

i have a problem with Insert from SAP to Sql Server

EXEC SQL.
open dbcursor for

INSERT INTO table_name
()
VALUES ()

Error Message

KERNEL_ERRID DBIF_DSQL2_SQL_ERROR

SQLCODE 7392

SQLMSG Unable to start a transaction for OLE DB provider "" of linked server "".

ENDEXEC.

Sandra_Rossi
Active Contributor
0 Kudos

You have empty values "()" in your SQL query. It fails obviously. What are you trying to achieve?

By the way, why are you using native SQL instead of recommended ABAP SQL?

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member717457
Participant

Hello Mohamed Aziz,

Pls. find below the code snipped - Inserting values from SAP to SQL/Oracle server vide Native SQL.

This worked for me.

REPORT ZSAMPLE.
data:
it_tab TYPE TABLE OF ZPRODUCT,
wa_tab TYPE ZPRODUCT,
lv_flag TYPE c.
*BREAK-POINT.

SELECT * from ZPRODUCT into TABLE it_tab.
EXEC SQL.
connect to 'ORCL' as 'ORA_DB'
ENDEXEC.

EXEC SQL.
set connection 'ORA_DB'
ENDEXEC.

* if sy-subrc eq 0.
*
* MESSAGE 'Testing Ok ' TYPE 'S'.
* endif.
loop at it_tab into wa_tab.
try.
EXEC SQL.

INSERT INTO CWORKS VALUES ( :wa_tab-PROD_ID,
:wa_tab-PROD_NAME,
:wa_tab-PROD_QTY,
:wa_tab-PROD_UOM,
:wa_tab-PROD_PRICE )

ENDEXEC.
ENDTRY.
if sy-subrc eq 0.
lv_flag = 'X'.
endif.
clear:wa_tab.
endloop.

if lv_flag = 'X'.
MESSAGE 'Record Inserted Successfully' TYPE 'S'.
endif.

Thanks

Sathish Kumar Sidhaiyan