[Zope] Last Insert ID?

Andy Dustman andy@dustman.net
26 Aug 2002 20:15:05 -0400


On Mon, 2002-08-26 at 18:13, 3205 5361 1215 9784 wrote:
> Hello zope,
> 
>   how can i get the last_insert_id() from mysql?
> 
>   i have a zsql function :
> 
>   select last_insert_id() as last_id
> 
>   but this doesnt work...

You probably need something like this:

INSERT INTO XXX (...) VALUES (...)
<dtml-var sql_delimiter>
SELECT LAST_INSERT_ID() AS last_id

Z SQL methods can have multiple statements, separated by <dtml-var
sql_delimiter>, but only one SELECT.

-- 
Andy Dustman         PGP: 0x930B8AB6
    @       .net     http://dustman.net/andy
"Cogito, ergo sum." -- Rene Descartes
"I yam what I yam and that's all what I yam." -- Popeye