Incrementing table id +1 with .save() | Community
Skip to main content
New Participant
April 17, 2024
Solved

Incrementing table id +1 with .save()

  • April 17, 2024
  • 2 replies
  • 628 views

Hello everyone,

 

I used the solution on this page to insert a data on the specific table:

https://experienceleaguecommunities.adobe.com/t5/adobe-campaign-classic-questions/how-to-get-an-id-of-a-newly-inserted-recipient-in-javascript/m-p/322274

 

But when I add a data from this query, the id generated is spaced as 30 value.

 

On the table I was added pksequence sql (pkSequence="deliveryRichSmsId") which allows you to increment the id to +1. (the sql was executed) : 

SELECT CreateSequenceIfNecessary('deliveryRichSmsId', '1000', 'cache 1');

 

var result = sqlExec("INSERT INTO RenDeliveryRichSms (iDeliveryRichSmsId) VALUES (nextval('deliveryRichSmsId'))");

 

With sqlExec() the value set up to +1
but I need to use the solution with ".save()" function to get the id generated.

=> The .save() spaces the id by +30 on each insertion.

 

Do you know if there is a solution to this?

 

Best regards,

Ali

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by _Manoj_Kumar_

Hello @ab_93 

 

It is recommended to not increment the counter by 1. The space is to allow the multiple ingestion at once otherwise it could create the duplicate key issue.

 

Could you please share more details on the use case?

2 replies

Sukrity_Wadhwa
Employee
May 2, 2024

Hi @ab_93,

Was the given solution helpful in navigating through your issue or do you still have the problem? Please share more details if you are still facing the issue. 

Thanks!

Sukrity Wadhwa
_Manoj_Kumar_
_Manoj_Kumar_Accepted solution
New Participant
April 18, 2024

Hello @ab_93 

 

It is recommended to not increment the counter by 1. The space is to allow the multiple ingestion at once otherwise it could create the duplicate key issue.

 

Could you please share more details on the use case?

     Manoj     Find me on LinkedIn