[Zope] ZSQL: UPdating a db entry with data from a query

Casey Duncan cduncan@kaivo.com
Thu, 05 Apr 2001 09:26:24 -0600


Phil Harris wrote:
> 
> Try <dtml-var "_['id']"> rather than <dtml-var id>
> 
> hth
> ----- Original Message -----
> From: "Gitte Wange" <gitte@mmmanager.org>
> To: <zope@zope.org>
> Sent: Thursday, April 05, 2001 3:44 PM
> Subject: [Zope] ZSQL: UPdating a db entry with data from a query
> 
> > Hello,
> >
> > I need to update a entry in my database with a rownumber minus one
> >
> > Okay I do this:
> >     <dtml-in FindTheRecord>
> >         <dtml-call UpdateTheRecord>
> >     </dtml-in>
> >
> > Now the FindTheRecord returns a record with a unique id-field. So I use
> > this field to update the record with but gets this error:
> > Error Type: Bad Request
> > Error Value: ['id']
> >
> > My sql for the methods looks like this:
> > FindTheRecord:
> > arguments: ordernum
> > SELECT * FROM playlistclips WHERE ordernum=<dtml-var ordernum>-1
> > This one works in test
> >
> > Update the record:
> > arguments: ordernum id (these are taken from the above query and are
> > fields in the above query-table)
> > UPDATE playlistclips SET ordernum=<dtml-var ordernum>+1 WHERE
> > id=<dtml-var id>
> >
> > Now I don't see what's wrong in doing this but Zope is :-)
> >
> > Regards,

ZSQL methods only look in the REQUEST object implicitly for values (not
the entire namespace like other methods). You must either put your
argument onto request or pass if explicitly to the method i.e.:


 <dtml-in name="FindTheRecord">
     <dtml-call expr="UpdateTheRecord(id=id)">
 </dtml-in>

You can also explicitly pass the entire namespace to a ZSQL method as
follows:

 <dtml-in name="FindTheRecord">
     <dtml-call expr="UpdateTheRecord(_)">
 </dtml-in>

-- 
| Casey Duncan
| Kaivo, Inc.
| cduncan@kaivo.com
`------------------>