Subject | RE: [firebird-support] Re: Looking for answer on ADO/ODBC Auto_Increment Return Value |
---|---|
Author | Alan McDonald |
Post date | 2005-01-03T21:22:06Z |
> > >I am using ASP (with VBScript) and ADO/ODBC to connect to my firebirdYou don't get the LAST insert ID, You get the ID before you insert.
> > >database. After countless hours of searching online I found a command
> > >"SELECT @@IDENTITY" for MSSQL to retrieve the value, but wonder if
> there is
> > >a similar command for Firebird or another work around.
> > >
> > >Thanks much in advance.
> >
> > The trick is to get it *before* you post the insert. There's an FAQ
> on the
> > website that tells you how to do it.
> >
> > ./heLen
>
> Hello Helen
>
> I have been trying to figure out a way to grab the id of the last
> insert for a multipage form. I use PHP and Firebird. It is easy in
> mysql, but I prefer Firebird ;) You mentioned a FAQ on the site.
> firebird.sourceforge.net ??? I can't find it. Or even googling does
> not turn up anything for Firebird. Can you post a link?
>
> Thanks
>
> David
Int PHP you do this
$newcontactid = $db->get_var("SELECT GEN_ID(GEN_CONTACT,1) FROM
RDB\$DATABASE");
and then do you insert.
Alan
PS: Note the backslash before the $DATABASE