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

Error in native SQL while inserting data into CORP table

Former Member
0 Likes
392

HI all,

I am getting an exception while inserting records using native SQL into CORP table.

PFB the code.

LOOP AT gi_hrp1001 INTO wa_hrp1001.
  TRY.
        EXEC SQL.
          INSERT INTO misuser.Table_4
          VALUES (wa_hrp1001-otype , wa_hrp1001-objid ).
        ENDEXEC.
      CATCH cx_sy_native_sql_error.
        MESSAGE 'Connect - Error ' TYPE 'E'.
    ENDTRY.
  ENDLOOP.

Please help.

Thanks & Regards

Nitesh

2 REPLIES 2
Read only

gabriel_pill-kahan
Active Participant
0 Likes
356

I see two issue with your Insert. 1) you need to specify the field names in the table, for example otype and objid. 2) You need to indicate in the VALUES that you're using host variables by using the prefix :.

I think the correct syntax is:


        EXEC SQL.
          INSERT INTO misuser.Table_4
         (otype, objid)
          VALUES (:wa_hrp1001-otype, :wa_hrp1001-objid)
        ENDEXEC.

Good luck.

Read only

Former Member
0 Likes
356

Thanks