Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread Problem with AutoIncrement field
Tue, Aug 12 2025 11:20 AMPermanent Link

Hershcu Sorin

Hello,

In my program, I have a table with an AutoIncrement field. When I run the program, I set the table to BeginCachedUpdates mode. After appending a few records to the table, I use the ApplyCachedUpdates command to save the records. At this stage, the program raises an error indicating that the Primary Key is violated due to a duplicate key value of 1.
I don't change the value of the Id field
What could be the problem?
Thu, Aug 14 2025 6:50 AMPermanent Link

Heiko Knuettel

Hi,

Just guessing - I'm not sure since I don't use CachedUpdates or AutoInc fields - but this might be a limitation. AutoIc fields increment once the row is written, and CachedUpdates prevent the rows from being written until later.

You could get the current AutoInc value before starting CachedUpdates and increment yourself. And hope that 3 other users don't do the same thing at the same time.

Heiko
Fri, Aug 15 2025 5:51 AMPermanent Link

Adam Brett

Orixa Systems

Hi Hershcu Sorin,

I agree with the other poster that this may be a limitation of EDB. Note that you could use a GUID as your primary key instead, or reference and external function that returns an Integer. If the function is triggered after-insert I am pretty sure it will work correctly even with the table in cached mode.
Image