Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Problem in using Native Sql with HANA

Hi,

I am fetching HANA views data using native sql in abap. I have observed a problem that sap is allowing only 29 execute sql commands statements in a row and gives dump for 30th query. My code is like below


  LO_CONN = CL_SQL_CONNECTION=>GET_CONNECTION( CONN1).

  LO_SQL_STMT = LO_CONN->CREATE_STATEMENT( ).



LOOP AT T_RANGE2 INTO WA_RANGE2.

       CONCATENATE 'INSERT INTO  VBELN_TEMP1 VALUES (' ''''WA_RANGE2'''' ')'  INTO LV_SQL_INS.

        TRY.

          LO_RESULT = LO_SQL_STMT->EXECUTE_QUERY( LV_SQL_INS ).

  

        CATCH CX_SQL_EXCEPTION INTO LX_SQL_EXC.

             LV_TEXT = LX_SQL_EXC->GET_TEXT( ).

            MESSAGE LV_TEXT TYPE 'E'.

      ENDTRY.

ENDLOOP.

Here I am passing a value range to VBELN_TEMP1 table of HANA through a loop on T_RANGE2 internal tab.

It works fine till TABX 29 and gives exits the program on 30th iteration.

Please help if anyone has observed same problem and found solution on it.

Thanks,

Shriniwas

Former Member
Former Member replied

For every loop iteration a new connection has been created with the old one still existing. You can avoid this by using COMMIT WORK at the end of TRY CATCH block.

       CATCH CX_SQL_EXCEPTION INTO LX_SQL_EXC.

             LV_TEXT = LX_SQL_EXC->GET_TEXT( ).

            MESSAGE LV_TEXT TYPE 'E'.

      ENDTRY.

  COMMIT WORK.  "INS 

ENDLOOP.

lo_conn->close( ). "INS

1 View this answer in context
Not what you were looking for? View more on this topic or Ask a question