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
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
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
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
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
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
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
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
-