Forum > Databases

The current value of AutoInc fields in a TDbf table

(1/6) > >>

SymbolicFrank:
Yet another TDbf question.

I am importing lots of data into a bunch of DBF files. AutoInc fields are set to the required value (it's complicated). When that is done, I have to set the value of the AutoInc fields to the correct maximum value. The current TDbf (trunk) supports AutoInc fields according to the wiki, but I cannot find where they are set or that max value is extracted from the DBF file. Does anyone knows?

Zvoni:

--- Quote from: SymbolicFrank on October 27, 2021, 01:56:41 pm ---When that is done, I have to set the value of the AutoInc fields to the correct maximum value.

--- End quote ---
I'm not even going to pretend to understand this.
Do you want to prevent the User to add new records to this table?
Since an AutoInc-Field is usually an Integer --> Max(UInt64)?

SymbolicFrank:
Although the wiki says that TDbf supports AutoInc fields, it really doesn't. I have to fill them myself. And the app that is going to use that database expects specific values across multiple tables (in the code the AutoInc fields are changed to Integer, so they can be inserted).

So, I make a counter and fill them with the correct value. But the current AutoInc value is stored in the table and has to be changed to the correct maximum value, so the next record is inserted with the correct number.

It's just a bunch of (mostly text) files. It's not a database server where referential integrity and AutoInc values are automagically enforced.

Zvoni:
If those fields must have specific values, then AutoInc is the wrong mechanism.
I have no experience with dbase (last contact being some 25 years ago), but does DBF (and a Query-Object?) support SQL?
Then it would be a simple SELECT MAX(MyAutoIncField)+1 FROM MyTable

SymbolicFrank:
I'm doing the conversion for an existing application. And, AFAIK there is no SQL. Just a directory full of files (tables, indexes, memo's, etc). It's more like MyStringList.LoadFromFile(ThisTable); MyStringList.Separator := Chr(0);.

Navigation

[0] Message Index

[#] Next page

Go to full version