Skip to Content
author's profile photo Former Member
Former Member

Insert into HANA does not work in ABAP

Dear experts,

I am very confused by the behavior of following statements:

EXEC SQL.

connect to 'HAN' as 'HAN'

ENDEXEC.

EXEC SQL.

create column table "C99P"."OUT_CCS"(

"SEQNO" TINYINT null,

"AKLASSE" CHAR (4) null,

"TEXT" CHAR (80) null,

"DEV_TYP" CHAR (40) null,

"C_PRICE" DECIMAL (5,4) null,

"O_ZWSTDIFF" DECIMAL (12,2) null,

"O_ZWSTDIFF1" DECIMAL (12,2) null,

"O_ZWSTDIFF2" DECIMAL (12,2) null,

"NETTOBTR" DECIMAL (14,2) null,

"NETTOBTR_QF" DECIMAL (14,2) null,

"NETTOBTR_FZ" DECIMAL (14,2) null,

"NETTOBTR_SG" DECIMAL (14,2) null)

ENDEXEC.

EXEC SQL.

insert into "C99P"."OUT_CCS" values ('0','A1NR','TEST','TEST',1,2,3,4,5,6,7,8)

ENDEXEC.

EXEC SQL.

disconnect 'HAN'

ENDEXEC

After the execution, I can see that the column table is successfully created from HANA studio, but no row is inserted. If I directly execute the same INSERT statement in SQL Editor, it works.😕

Any advice will be highly appreciated!

Kind regards,

Jerry

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    Posted on Jun 11, 2012 at 04:19 PM

    Hi Jerry,

    Can you please check couple of things like how the Auto commit is set. It should be on. if not, try to set the commit after the insert statement. Also try to catch the exception to check the error code (if any). Please check the data type in the insert statement for implicit conversion from char to tinyint etc.

    There is a similar thread on another forum (though not answered, but might help).

    http://scn.sap.com/thread/2112168

    Also I am sure you had read the nice blog written by Thomas Jung on using SQL in ABAP.

    http://scn.sap.com/community/in-memory-business-data-management/blog/2012/04/11/test

    Regards,

    Ravi

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Ravi,

      Just tested Jerry's code from his message in my test instance out of interest and you are right, INSERT worked with an explicit COMMIT statement. It seems to suggest that the ABAP secondary database connection that is established does not take into account the AUTO COMMIT setting from the HANA studio database session.

      I would have expected the CONNECT TO statement to have a clause to connect with auto commit option but not sure what the syntax is for that.

      Thanks,

      Anooj

  • author's profile photo Former Member
    Former Member
    Posted on Jun 13, 2012 at 03:49 AM

    Hi Jerry

    By taking the above into consideration, you can try below syntax , it works for me, please let us know if you are still facing any challenges.

    stmt_ref type ref to cl_sql_statement,

    stmt_ref->execute_update('insert into Schemaname.EMP_DEPT values (473890,552,''SUP'')').

    Thanks

    Santosh Varada

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 14, 2012 at 02:58 PM

    Hi guys,

    Thanks a lot.

    COMMIT and ADBC work for me now. Thanks.

    Kind regards,

    Jerry

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.