Re: [gnome-db] Access to last auto_increment value (mysql_insert_id)



On Mon, 2004-03-08 at 11:23 -0500, Adam Williams wrote:
> On Fri, 2004-03-05 at 05:09, Rodrigo Moya wrote:
> > On Thu, 2004-03-04 at 23:56 +0000, Nigel Titley wrote:
> > 
> > > Gentlefolk,
> > > 
> > > I'm building an application using libgda as an abstraction layer over a
> > > mysql database. I am using the auto_increment column type to generate
> > > unique ids for each row in a table. My question is: is it possible to
> > > access the generated id after executing the INSERT. If I was using the
> > > mysql API directly, I would use the mysql_insert_id() function, but
> > > despite a diligent search of the documentation, the archives of this
> > > list, and the gda-mysql source code, I can't seem to see a way of doing
> > > this. Without this functionality, the auto_increment facilty is of
> > > limited usefulness.
> > > 
> > > Can someone point me in the direction of documentation that could help
> > > me? 
> > > 
> > there is no direct way to get it. I guess the best thing would be, in
> > libgda 1.2, to set the ID on the field on insertion, and have the data
> > model's new added row have that value in the corresponding field. Thus,
> > you'll have just to read the field in the new row.
> > 
> > I'll add it to the 1.2 code soon.
> 
> Isn't there SELECT DBINFO("SQLCA.SQLERRD1") like functionality?
> 
> I think I've seen statements like "select LAST_INSERT_ID();" in MySQL
> applications.  I have no idea excatly what it means as I don't use
> MySQL.
> 
I think I'm going to add a get_last_insert_id virtual method to the
GdaServerProvider, to be implemented by each provider. Anyone has any
objections?

cheers




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]