[EMAIL PROTECTED] ha scritto:
> Hi Doriano
>
> As the description says, the last_inserted_id() is during the same 
> connection reserved for the client.
> I would recommend to use a stored procedure. Indeed, why not delegate 
> the SQL thing to the server.
> The first time it seems to be expensive, but it is not so. I would be 
> helpful if necessary.
>
> Regards, Werner(007)
>   
This would be cool. I never used stored procedures, even if I read about 
them.
So my problem (and other's, I suppose) is:

1: Create a master record with unique ID and several other fields in 
table "invoices"
2: Obtain the inserted ID
3: Add one or more (sometimes a lot) slave records, each carrying the 
obtained ID, and other fields.

I think a stored procedure wants all its parameters in a single call, or 
it is not so?
If you can help, I will be happy - thanks.

Doriano.

>>> [EMAIL PROTECTED] ha scritto:
>>>   
>>>       
>>   
>>     
>>>>> But in case you are using mySQL there is the function LAST_INSERT_ID (),
>>>>> see: 
>>>>> http://dev.mysql.com/doc/refman/5.1/en/information-functions.html#function_last-insert-id.
>>>>>     
>>>>>           
>>>     
>>>
>>>       
>     db.exec("insert data in master table 'invoices'")
>     lastinserted=db.exec("select last_insert_id() as last")
>
> Perhaps locks are still needed (or this last_insert_id() is "cached" in 
> the client library? It would be good...)
>   

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user

Reply via email to