Re: [Gambas-user] mysql last_insert_id

2012-07-17 Thread Bill-Lancaster
Thanks guys, Yes, the field is auto-increment. Having just discovered it, I thought "last_insert_id" would be a bit more elegant than MAX(). Thanks again -- View this message in context: http://old.nabble.com/mysql--last_insert_id-tp34173030p34177606.html Sent from the gambas-user mailing l

Re: [Gambas-user] mysql last_insert_id

2012-07-17 Thread Caveat
Have you got auto_increment on the id field? http://dev.mysql.com/doc/refman/5.0/en/example-auto-increment.html Seems last_insert_id() looks at the previously-run SQL statement that performed an INSERT. If you're running this query in a separate program, or have done other SQL operations since

Re: [Gambas-user] mysql last_insert_id

2012-07-17 Thread Bruce
On Tue, 2012-07-17 at 04:14 -0700, Bill-Lancaster wrote: > I have a table (editprojects) with "id" as primary key, serial, integer. > There is only one record at the moment (id = 1) > hResult = hConn.Exec("SELECT last_insert_id() as id FROM editprojects") > print hResult!id > produces 0 not 1

[Gambas-user] mysql last_insert_id

2012-07-17 Thread Bill-Lancaster
I have a table (editprojects) with "id" as primary key, serial, integer. There is only one record at the moment (id = 1) hResult = hConn.Exec("SELECT last_insert_id() as id FROM editprojects") print hResult!id produces 0 not 1 Obviously my sql query is at fault but where? I wonder if anyone

Re: [Gambas-user] MySQL last_insert_id value

2012-01-20 Thread tobias
On 20.01.2012 23:46, Keith Clark wrote: > On 12-01-20 05:14 PM, tobias wrote: >> hi, >> >>> How would I get the MySQL last_insert_id() value into an integer >>> variable inside gambas? >>> >>> I tried with >>> >>> CurrentID=db.exec("select last_insert_id() as last") >>> >>> but I get a type mismatc

Re: [Gambas-user] MySQL last_insert_id value

2012-01-20 Thread Keith Clark
On 12-01-20 05:14 PM, tobias wrote: > hi, > >> How would I get the MySQL last_insert_id() value into an integer >> variable inside gambas? >> >> I tried with >> >> CurrentID=db.exec("select last_insert_id() as last") >> >> but I get a type mismatch error. Expecting integer, got result. >> >> Thank

Re: [Gambas-user] MySQL last_insert_id value

2012-01-20 Thread tobias
hi, > How would I get the MySQL last_insert_id() value into an integer > variable inside gambas? > > I tried with > > CurrentID=db.exec("select last_insert_id() as last") > > but I get a type mismatch error. Expecting integer, got result. > > Thanks, > > Keith > i suppose CurrentID is an integer

[Gambas-user] MySQL last_insert_id value

2012-01-20 Thread Keith Clark
How would I get the MySQL last_insert_id() value into an integer variable inside gambas? I tried with CurrentID=db.exec("select last_insert_id() as last") but I get a type mismatch error. Expecting integer, got result. Thanks, Keith -