Board index » delphi » BDE Autoincrement Fields

BDE Autoincrement Fields

        Folks,
        When using the BDE tools I can create a database structure with
a field type of "Autoincrement".  This is very useful for me since it
allows each record to have a unique identifier, which can be indexed.

If I use the Database Desktop to enter data, these fields are properly

maintained, however if I use a Delphi program to insert a new record,
this field doesn't seem to be effected.  Nor does there seem to be a
field type which can be used in the "TTable.FieldDefs.Add()" method,
and thence from the "TTable.CreateTable" method, to programaticaly
create such a field.  The README.TXT file already states that
CreateTable doesn't support the "Formatted Memo" field type, is it
possible that the wiz kids at Borland let another field type slip
through the cracks?  Is there anyone out there preping another patch
release?  Does anyone with the VCL source feel like patching this then
releasing it?  Am I just barking up the wrong tree?

                                                        Fritz
--
Fritz Lowrey                          jlow...@ucs.usc.edu
USC Computer Services                 Phone: 213 740-5160

 

Re:BDE Autoincrement Fields


Quote
In article <3roq3f$...@usc.edu> jlow...@ucs.usc.edu (Fritz Lowrey) writes:
>Path:
>        Folks,
>        When using the BDE tools I can create a database structure with
>a field type of "Autoincrement".  This is very useful for me since it
>allows each record to have a unique identifier, which can be indexed.
>If I use the Database Desktop to enter data, these fields are properly
>maintained, however if I use a Delphi program to insert a new record,
>this field doesn't seem to be effected.
snip
>                                                        Fritz
>--

Call TTable.Refresh after inserting the record and the numbering will
be autoincremented.

Eleanor Howick
E.How...@irl.cri.nz
Industrial Research Limited
PO Box 31-310
Lower Hutt
New Zealand.
Phone: +64-4-569 0000
Fax : +64-4-569 0515

Re:BDE Autoincrement Fields


Quote
Eleanor Howick (e.how...@irl.cri.nz) wrote:

: Call TTable.Refresh after inserting the record and the numbering will
: be autoincremented.

        Actually this is unnecessary (at least in my experience with
Paradox and InterBase local and server versions) if you don't need the
value of the key.  When TTable.Post is called, the key is generated and
stored.  The only real catch to this is that the primary key must have a
value in it or Delphi will give an error message.  The value does not
matter as Delphi properly generates and stores the key on Post.  Calling
TTable.Refresh simply will update the TTable.Fields structure with the new
key value.

Mike.

--
====================================================================
Mike Frisch                           Email: mfri...@saturn.tlug.org
Northstar Technologies                        Compuserve: 76620,2534
Newmarket, Ontario, CANADA

Re:BDE Autoincrement Fields


Actually, you want to be careful with Autoincrement.
I had a similar discussion on CServe regarding a
similar problem.

Should the table/indexes get corrupted (as often
happens in a shutdown, reboot, etc), you will need
to run a repair function on the table.  The repair
function will sequentially renumber all autoincremented
fields.

If you used the original as a foreign key in another
table, your links are lost.

I chose to derive a TTable component to use as a sequence
generator (TSequence) something like Oracle 7's sequences.

Just my thoughts...

 - Mike

Other Threads