[Zope] ZSQL dtml request problem
Thu, 12 Jun 2003 19:15:35 +0200
On Thu, 12 Jun 2003 17:11:43 +0100 GMT (..18:11 where i live(GMT+2) )
Davis Mr MR asked the Zope mailinglist about the following:
> I'm trying to push the last_inset_id from an Insert statement onto the
> request namespace, so I can pick it up and retrieve the new record for
> My ZSQL method looks like this.
> INSERT INTO suppliers (insert statements removed)
> <dtml-var sql_delimiter>
> SELECT last_insert_id() AS lastinsertid
> <dtml-call "REQUEST.set('id',lastinsertid)">
> It comes back with a NameError - global name 'lastinsertid' is not defi=
> How do I either get the dtml-call to see the lastinsetid variable, or g=
> the value by using the sql statement inside the dtml-call statement.
Your problem is that DTML and SQL are not executed at the same time.
First the DTML is parsed to make the SQL statement, then the SQL is
shipped off to the database.
if you just lose the dtml-call, i would guess this method would return
a single row with a property lastinsertid..
so , the calling script/template, could probably get to the
value lastinsertid like this