|
Hi everyone - hope you all had a good break. Looks
like summer has finally arrived (now that everyone's back at work)!
Anyway...
I'm using Firebird (and transactions) for the first
time. I'm connecting to a remote database via the Firebird Server with no
problems, but I have a question about transactions:
When I insert a new record, I use a trigger and a
generator to generate a new unique ID for the new record - I also query the
generator to see what the new value is that was returned by the trigger. The
code snippet is as follows:
orderTransaction.Active
:= True;
with orderQuery do //insert the record begin ExecQuery; with IBCurrentGeneratorValueQuery do // this query fetches the current value of the generator try Transaction := orderTransaction; // share the same transaction as the order Open; result:=FieldByName('newID').asInteger; // get the generator value except result:=-1; end; orderTransaction.Commit; end; The question is, if multiple clients access the
database server at the same time, will IBCurrentGeneratorValueQuery still return the correct value, or if
another concurrent transaction on another thread increments the generator, will
this query return the wrong value?
When I was using MySQL (with PHP) I could use
mysql_insert_id() to query the new key value. I guess that if I could
get hold of the newly inserted row I could just get the field value, but the
same concurrency issue applies and I'm not sure how to get the record I just
inserted.
Cheers,
Phil.
|
_______________________________________________ Delphi mailing list [email protected] http://ns3.123.co.nz/mailman/listinfo/delphi
