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

ADBC Insert Query not working

Former Member
0 Likes
3,170

Hi Experts,

I am trying to insert records in database table, but its failing.

When I debug the statement, the CALL C_DB_FUNCTION returns sy-subrc 12.

Here is my code for insertion :

Create the SQL statement object

  lo_sql_statement = lo_sql_connection->create_statement( ).


* To insert the records from internal table

  lo_sql_statement->set_param_table( REF #( lt_materialid ) ).


* Prepare the SQL Statement

  CONCATENATE 'INSERT INTO' c_tab_name 'VALUES( ?,? )' INTO

                   lv_sql_statement SEPARATED BY space.   " #EC NOTEXT

* Execute the SQL statement

   TRY .

    lv_rows_processed = lo_sql_statement->execute_update( lv_sql_statement ).

   CATCH cx_root INTO lx_root .

EXECUTE_UPDATE Method is not working.

Any reviews in this??

Thanks,

Sumit

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,204

Hi All,

The problem for INSERT is solved. Since I am having 3 columns in my internal table, so the INSERT statement has to be changed.

it should be

INSERT INTO dbtab VALUES ( ?,?,? ). with 3 questions marks.

Thanks,

Sumit

Hi All,

The problem for INSERT is solved. Since I am having 3 columns in my internal table, so the INSERT statement has to be changed.

it should be

INSERT INTO dbtab VALUES ( ?,?,? ). with 3 questions marks.

Thanks,

Sumit

6 REPLIES 6
Read only

pfefferf
Active Contributor
0 Likes
2,204

Hello Sumit,

how does the structure of your internal table lt_materialid and the structure of the db table (identified by c_tab_name) look like? Do the columns for which you wanna insert data match?

Did you you check the error messages in the possible raised exception (using method GET_TEXT, GET_LONG_TEXT)? The exception should be normally of type CX_SQL_EXCEPTION.

Regards,

Florian

Read only

Former Member
0 Likes
2,204

Hi Florian,

Thanks for the reply!!

The structure for both Internal table and Database table are same. Both have 3 columns.

When I dig deep into the exception it is just giving "EXTERNAL ERROR".

Same is the problem with "UPDATE". Update command is not working when I try to update multiple entries in a dbtab via internal table.

Thanks,

Sumit

Read only

pfefferf
Active Contributor
0 Likes
2,204

Hello Sumit,

can you show the structure of the table and the internal table + one data record you try to insert and which fails.

Thx.

Florian

Read only

amol_samte
Contributor
0 Likes
2,204

As suggested by Florian you can get exact message in exception.

As well as you can check the user used for secondary DB has appropriate rights.

-Amol

Read only

Former Member
0 Likes
2,205

Hi All,

The problem for INSERT is solved. Since I am having 3 columns in my internal table, so the INSERT statement has to be changed.

it should be

INSERT INTO dbtab VALUES ( ?,?,? ). with 3 questions marks.

Thanks,

Sumit

Read only

Former Member
0 Likes
2,204

Thanks alot ..