Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

The 4th edition of the Campaign Community Lens newsletter is out now!

Insert or Update using xtk.session.Write

Avatar

Level 2

Hi,

Can anyone please confirm if the below approach is correct if we want to insert or update the data in a table using JS?

 

insertUpdateQuery = <order _key="@custId,@productName,@subProductName" _operation="insertOrUpdate"  xtkschema = "cus:order"
productName = { productName }
subProductName = { subProductName }
custId = { custId }
productid= { productid}
datetime = { datetime }
/>
xtk.session.Write(insertUpdateQuery);

 

We are getting duplicate key value violates unique constraint errors in logs as during insertion or updation we can get data that might be already present based on the 3 key fields.

Based on my understanding if we use insertorUpdate operation it should not give a duplicate error. Can anyone please with this?

Version is V8

Thanks 

 

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

2 Replies

Avatar

Level 6

Hi @ratika ,

 

Your write function and understanding related to "insertOrUpdate" operation are correct, as if there is a value that exists post the reconciliation of _key then the "insertOrUpdate" will update that record else it will insert.

Did you try to run the same js function in any other workflow to check if there are any caching/corruption issues in the current wkf?

Also, did you try to use _operation="update" (for testing) to observe if this also returns the same error of duplicate key?

 

Br,

Shubham

 

Avatar

Administrator

Hi @ratika,

Were you able to resolve this query or do you still need more help here? Do let us know.

Thanks