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

Reg: Exception on INSERT Statement

Former Member
0 Likes
4,574

Hi Friends,

I am getting the CX_SY_OPEN_SQL_DB type of exception quit offen.

There is no duplicate records in the table. still i am gettin the

exception.

TRY.

INSERT ZSC_FOUNDRY_RECS FROM TABLE IT_VAL_FOUNDRY_RECS.

CATCH CX_SY_OPEN_SQL_DB.

ROLLBACK WORK.

MESSAGE I234. "Error occured while inserting record into ZSC_FOUNDRY_RECS table

ENDTRY.

Could any one tel mem, what could be the reason for this?

10 REPLIES 10
Read only

Former Member
0 Likes
2,507

Dont check the database table , check the internal table content from which the records are inserted and also consider blank values of field while doing so.

Read only

0 Likes
2,507

I have checked bot the Internal table and the Database table.

Another thing is I dont want to modify the record. If the record is already present, then i should not insert into the database.

Read only

0 Likes
2,507

Hi,

Check if you have the MANDT field in your internal table.

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
2,507

>

> Another thing is I dont want to modify the record. If the record is already present, then i should not insert into the database.

Hello,

This means that you must use INSERT statement only. UPDATE & MODIFY are not to be used.

Also FYI if you try to insert a record with the same key which exists in the DB you will get the exception DBIF_RSQL_KEY_ALREADY_EXISTS of class CX_SY_OPEN_SQL_DB.

May be you can get the text of this exception & check what is the error you are getting:

data OREF type ref to CX_ROOT.
data TEXT type STRING.

    CATCH CX_SY_OPEN_SQL_DB into OREF.
      TEXT = OREF->GET_TEXT( ).

BR,

Suhas

Edited by: Suhas Saha on Nov 23, 2009 11:37 AM

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
2,507

change it as

MODIFY ZSC_FOUNDRY_RECS FROM TABLE IT_VAL_FOUNDRY_RECS

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
2,507

change it as

MODIFY ZSC_FOUNDRY_RECS FROM TABLE IT_VAL_FOUNDRY_RECS.

i hope the IT_VAL_FOUNDRY_RECS structure is same as of ZSC_FOUNDRY_RECS

Read only

Rocky1
Product and Topic Expert
Product and Topic Expert
0 Likes
2,507

Hi,

Try these things:

1) Use COMMIT WORK AND WAIT after Insert and update statement to release the lock.Check for sy-subrc = 0.

2) Use Select single for update instead of Select single.

3) Rollback if insert statement fails.

4) Try to catch the exception by inserting exception block.

Thanks & Regards

Rocky.

Read only

Former Member
0 Likes
2,507

I have a question, Is there a possibility that, i have inserted records from internal table. I have not used the commit work statement. then i am having another insert statement, where i am trying to update the DB from another internal table.

Wheter, any exeception will be raised?

Read only

Rocky1
Product and Topic Expert
Product and Topic Expert
0 Likes
2,507

Hi,

Yes, exception will be raised, if within a loop you are trying to insert a data and without committing trying to update or read the data in the next loop pass.

Thanks & Regards

Rocky

Read only

RaymondGiuseppi
Active Contributor
0 Likes
2,507

CX_SY_OPEN_SQL_DB not always refer to duplicate records, try to find the actual error in SM21 syslog. (there can be mapping errors on numeric or complex string fields)

Regards,

Raymond