Subject | RE: [firebird-php] auto increment last insert |
---|---|
Author | Alan McDonald |
Post date | 2004-11-24T23:54:08Z |
Sorry - I read it as you comparing FBs method with MySQLs method of getting
the insterted PK value.
To make it clear for Johan,
MySQL uses a method whereby you insert a record, THEN you ask the server
what value it used for the last insert. You can't therefore insert into
another table in the meantime because it will give you that table ID
instead. You must insert then retrieve, insert then retrieve and this is on
a connection by connection basis so noone else can get your insert value and
you must remain connected during this process.
FB provides for you to get a value anytime you like for whatever purpose you
wish (PK values or even filenaming for client applications). The value does
not pertain to a table PK unless you use it to insert into a table. You are
assured that the value is unique in the context of that generator name and
you may discard it if you wish and it will never occur again and be forever
lost (barring you doing something silly like use a SET GENERATOR call to
reset the values)
FB generators are also created out of the context of any running
transaction. If you rollback the current transacion, the generator value
does not get rolled back.
Alan
-----Original Message-----
From: Nigel Weeks [mailto:nweeks@...]
Sent: Thursday, November 25, 2004 10:31 AM
To: firebird-php@yahoogroups.com
Subject: RE: [firebird-php] auto increment last insert
I meant the idea of using GEN_ID(generatorname,0) in FIREBIRD to get the
last ID used...not MySQL.
In between the time your insert has finished, and the time you fetch the
,0
from the generator, it could have been called 100 times...
Sorry for the confusion...
Nige.
Yahoo! Groups Sponsor
Get unlimited calls to
U.S./Canada
----------------------------------------------------------------------------
--
Yahoo! Groups Links
a.. To visit your group on the web, go to:
http://groups.yahoo.com/group/firebird-php/
b.. To unsubscribe from this group, send an email to:
firebird-php-unsubscribe@yahoogroups.com
c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
[Non-text portions of this message have been removed]
the insterted PK value.
To make it clear for Johan,
MySQL uses a method whereby you insert a record, THEN you ask the server
what value it used for the last insert. You can't therefore insert into
another table in the meantime because it will give you that table ID
instead. You must insert then retrieve, insert then retrieve and this is on
a connection by connection basis so noone else can get your insert value and
you must remain connected during this process.
FB provides for you to get a value anytime you like for whatever purpose you
wish (PK values or even filenaming for client applications). The value does
not pertain to a table PK unless you use it to insert into a table. You are
assured that the value is unique in the context of that generator name and
you may discard it if you wish and it will never occur again and be forever
lost (barring you doing something silly like use a SET GENERATOR call to
reset the values)
FB generators are also created out of the context of any running
transaction. If you rollback the current transacion, the generator value
does not get rolled back.
Alan
-----Original Message-----
From: Nigel Weeks [mailto:nweeks@...]
Sent: Thursday, November 25, 2004 10:31 AM
To: firebird-php@yahoogroups.com
Subject: RE: [firebird-php] auto increment last insert
> [Alan McDonald] Nigel I don't think this is correct. TheSorry, must have worded it badly.
> MySQL return of the
> last insert ID is done on a connection by connection basis.
> If you remain
> connected between tne insert and the query for lastinsert
> value, noone else
> can ever get that value.
> Alan
>
I meant the idea of using GEN_ID(generatorname,0) in FIREBIRD to get the
last ID used...not MySQL.
In between the time your insert has finished, and the time you fetch the
,0
from the generator, it could have been called 100 times...
Sorry for the confusion...
Nige.
Yahoo! Groups Sponsor
Get unlimited calls to
U.S./Canada
----------------------------------------------------------------------------
--
Yahoo! Groups Links
a.. To visit your group on the web, go to:
http://groups.yahoo.com/group/firebird-php/
b.. To unsubscribe from this group, send an email to:
firebird-php-unsubscribe@yahoogroups.com
c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
[Non-text portions of this message have been removed]