2016 Jun 17 7:53 AM
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
2016 Jun 21 6:14 AM
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
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
2016 Jun 20 6:06 AM
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
2016 Jun 20 6:18 AM
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
2016 Jun 21 5:48 AM
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
2016 Jun 20 6:56 AM
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
2016 Jun 21 6:14 AM
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
2016 Jun 30 1:15 PM
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |