Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating AutoIncrement in Interbase SQL DataBase? 1

Status
Not open for further replies.

delphiman

Programmer
Dec 13, 2001
422
ZA
Can someone perhaps give me some ideas please?

Unlike an MS-SQL DataBase the IB-SQL dataBase does not have an "AutoIncrement" field and one has to handle this with a Generator.

Which works fine BUT the number does not arrive into the field "UponNewRecord" as I would have expected - so that UpDate crashes.

I can force a (hard-coded) "1" into it - which works with the DataBase simply correcting it to whatever the number
is supposed to be when I leave the program - when for some mysterious reason THEN UpDate works. As becomes obvious after I go back into the program.

But that is too late for what I am doing.

Does anyone know the appropriate code, as in "INC(MyTableTheField)" ...(something?) ....whereby the correct number will be forced into the field?

 
Hi Terry we had that discussion in the Interbase Forum


How do I make an field that is autoincremental in Interbase?
thread756-82472

I will look-up my sources for the underlying delphi code!!

Steven van Els
SAvanEls@cq-link.sr
 
The Details:

The required data-aware control for ID-Field is a dbText

Double click your Ttable to bring up the Fields editor
Change the ID-Field property Required to false. This will keep your application from requiring a value for the ID-Field, the generator will do the work

Click the Object Inspector's Events page for the table
Double click the Afterpost event and key in
MyTable.Refresh

The call to TDataSet refresh updates the Data

With a query you will need to close and open the dataset (Query)

Steven van Els
SAvanEls@cq-link.sr
 
Nice hearing from you again Stephen.
Hope things are going well at the refinery! :)

Thanks for your (ever useful) help.

For your interest Otto also has a good idea in the IB- Forum
thread756-525979.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top