cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Unable to insert data getting ENTITY_ALREADY_EXISTS

0 Kudos
3,187

1. I am trying to bulk insert records using the following query:

DAO.INSERT.into(entity).entries(toInsert)

2. But I end up with the following error:

{"code":400,"message":"ENTITY_ALREADY_EXISTS","numericSeverity":4}

even though there are no duplicates in the table

Accepted Solutions (1)

Accepted Solutions (1)

tim_schulze-hartung
Product and Topic Expert
Product and Topic Expert

Hi Mujeeb,

thanks for providing context.

You most probably are using some 'unique' constraint in your DDL (e.g., `@assert.unique` in CDL) and there is an error connected with this – so some data affected by the constraint seems to be present already.

Unfortunately there is a known issue as to the original error message getting lost.

Hope these hints help you.

Regards,
Tim

Answers (2)

Answers (2)

0 Kudos

Hi Tim,

Thank you for the help. This hint helped me understand the root cause.

The issue was that the array which I was sent to be uploaded had a duplicate record within in. I was not aware of that and was checking on all other places as it sent ENTITY_ALREADY_EXISTS error which put me off track.

tim_schulze-hartung
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hello Mujeeb,

please provide more context: Which products and programming language do you use and on which platform?

Regards, Tim

0 Kudos

Sure, Tim.

Following are the details:

1. The DB here is Hana and I am using CDS queries to update and insert data.

2. I am using Node.js

3. I am doing the development on the BAS and the services are deployed on Cloud Foundry.

To add more details here:

1. I deleted a few entries from Hana's SQL console.

2. We have an auto cron [batch job] which fetches data from C4C and then process them and updated the Hana database/

3. Fetching and proccessing is workig right but the save/update is failing with the above error.