Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 2 of 2 total
Thread set last autoInc value programmatically
Sat, Aug 30 2014 5:22 AMPermanent Link

Kees

I took over a Delphi project and I want to change the structure of a table. The table has a field 'id' which is the primary key, but it is not autoInc. On insert, the program randomly tries values (integer) for the field id until it succeeds (no duplicates).
I want to change the structure to autoInc. The program uses a very old version of dbisam. The format version of the table is 3.0. Dbisam itself is version 3.30.
What's strange is that dbSys says that the last autoinc value of the current table is 101325 (it has no autoinc field). Which is to me a random number.
To do the change to autoinc, I remove the field id, save the table and add the field id again. But now the field id is integer + primary key + autoinc.
If I do that the last autoinc value is still 101325.
I tried to repair the table before starting the procedure and I tried repair on the table with the autoinc field, but no luck.
I can change last autoinc value in dbsys and it works. Unfortunatly I have to set the last autoInc value programmatically in a update program that changes the tablestructure invisible for users of the application.
What can I do?

Kees
Sat, Aug 30 2014 10:01 AMPermanent Link

Raul

Team Elevate Team Elevate

Kees

You're in the EDB newsgroup but your question is about DBISAM (different
product) - you usually get a better response from appropriate group.

> I can change last autoinc value in dbsys and it works. Unfortunatly I have to set the last autoInc value programmatically in a update program that changes the tablestructure invisible for users of the application.
> What can I do?

dbsys is a regular delphi program using the same components so if it can
do it then you app can as well.

I have not used the dbisam3 for a long time but it should be similar to
DBISAM4 which is you need to call AlterTable and specify the new
NewLastAutoIncValue,

Since it's the only value you need to change you need to load existing
field and index definitions and use existing defaults for other values.

See this for DBISAM4 - DBISAM3 manual should have a similar section :
http://www.elevatesoft.com/manual?action=viewtopic&id=dbisam4&product=rsdelphi&version=2007&topic=Creating_Altering_Tables

Raul
Image