Mailing List Archive

newbie DTML: multiple WHERE
I'd like to pass in a string and a list to a ZSQL method.
For example:
user: foo
ids: [1, 2, 3, 4, 5]

I'd like to create a ZSQL method that does an update on multiple rows.
For example:

Arguments: user, ids
(string, list)

UPDATE myTable
SET Owner = <dtml-sqlvar user type="string">
WHERE Id IN <dtml-sqltest ids type=int multiple>


I'd like the SQL to look like this:

UPDATE myTable
SET Owner = foo
Where Id IN (1,2,3,4,5)

I wish there were more examples up online for ZSQL, especially for those
of us who are using ZPT, and DTML is somewhat foreign. For example, could
I use a dtml-sqlgroup or dtml-in to solve this?

tia!

- Mike
_______________________________________________
Zope-DB mailing list
Zope-DB@zope.org
http://mail.zope.org/mailman/listinfo/zope-db
Re: newbie DTML: multiple WHERE [ In reply to ]
On 2005-05-22 at 19:43:31 [+0200], Michael Schwartz <mike@ziacom.us> wrote:
> UPDATE myTable
> SET Owner = foo
> Where Id IN (1,2,3,4,5)
>
> I wish there were more examples up online for ZSQL, especially for those
> of us who are using ZPT, and DTML is somewhat foreign. For example, could
> I use a dtml-sqlgroup or dtml-in to solve this?

Personally I would recommend you use as little DTML as possible in your
ZSQL as it makes debugging it a lot easier.

The following should work

UPDATE myTABLE
SET Owner = 'foo'
WHERE id IN <dtml-var ids>

you can user dtml-var to pass in a Python list that will not be quoted.

Charlie
--
Charlie Clark
eGenix.com

Professional Python Services directly from the Source
>>> Python/Zope Consulting and Support ... http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
________________________________________________________________________

::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! ::::
_______________________________________________
Zope-DB mailing list
Zope-DB@zope.org
http://mail.zope.org/mailman/listinfo/zope-db
RE: newbie DTML: multiple WHERE [ In reply to ]
Hi,

Try something like:

update mytable
set owner=<dtml-sqlvar user type=string>
<dtml-sqlgroup where>
<dtml-sqltest ids op=eq column=id type=int multiple>
</dtml-sqlgroup>



Regards, Josh
_______________________________________________
Zope-DB mailing list
Zope-DB@zope.org
http://mail.zope.org/mailman/listinfo/zope-db