Le 26/11/2013 16:02, Kovács László a écrit :
Hi dear list members.
I'm new here. Approximately 17 years ago I worked as a sysadmin, gave
every day support for 70 peoples how to use their computers. I also
made numerous small apps, to help the work of the firm. That time I
did it with Delphi 1, used DBase and Paradox tables.
I did this job for a few years, then the life pushed me away from
programming, but not too far away from computers.
Now I'm here, and seem to come back.
My friend wants me to create a database app, because the task is just
too complicated to do by himself in MS Access.
I put my cents on Lazarus, as I can't afford any Delphi (and like)
available today.
I choosed Firebird (a very cost effective solution as well) as
database engine, started with embedded, but later when as development
progresses need move to real client-server.
So, I created my database, that wasn't too hard with IBExpert personal
(I had to look for something to substitute Database desktop).
I also managed to create my autoinc fields, using Firebirds triggers
and generators. Each of my tables has its own counters.
But I'm stuck with getting the newly inserted rows ID.
How do you get it?
Create as many sequences (new name for generators) as you need
In the application when you need a new value for a sequence (an insert
for instance) I execute the next query just before:
*/select next value for my_generator_name as column_name_i_want from
rdb$database/*
and I get the value with the query which executed the query (some TQuery
component, using FieldByName('column_name_i_want).AsInteger or better
AsLargeInt)
The unique ID has been definitely reserved and the I can use it into any
other update or insert with other tables.
This is my way but it not the only one but because I want to control
everything which reports to database, i'm used to this method
Antonio.
Or if you generate the ID on the client side, how do you make
absolutely sure, no other user can get the same ID.
That's easy: it is guaranteed by Firebirdwhatever way you choose
Is there a way to ask Firebird about the next value of a generator?
And then I could use that ID upon an insert, and would deactivate the
triggers.
yes, read above, no need to deactivate or reactivate triggers
If I'm on a wrong way with this ID thing, any other "Best practices"
are welcome. ;)
I highly appreciate every help word!
Thank you very much in advance
Laszlo Kovacs
--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus