[Zope] newbie - odbc missing operator
Rob Page
rob.page@digicool.com
Mon, 16 Aug 1999 19:03:29 -0400
> Thanks for the pointer. Let's get into some Z stuff. How does
> one do the
> following?
> Instead of the string '(918)' we need to select for a list of
> areacodes.
> i.e. (918), (404), (950).
>
> something like ...
> select name, phone from contact where phone LIKE '(918)%' OR
> phone LIKE
> '(404)%'....
> should be built using DTML???
> but how?
Well, if it were me, I'd munge the data and get the areacode into its
own field and do MUCH more efficient SQL = operators...
Alternatively, assuming you had a form variable called areacodes:list
<UNTESTED ZSQL Method CODE>
SELECT stuff FROM contact
<!--#sqlgroup where optional-->
<!--#in areacodes-->
phone LIKE '(<!--#var sequence-item-->)%' <!--unless sequence-end-->
OR <!--#/unless-->
<!--#/in-->
<!--#/sqlgroup-->
If the user doesn't select any areacodes the sqlgroup (with the optional
tag) will render:
SELECT stuff FROM contact
If there are one or more areacodes in the list it will render something
like:
SELECT stuff FROM contact
where
phone LIKE '(540)%' OR
phone LIKE '(703)%' OR
phone LIKE '(813)%'
or at least it looks like it should! :^)
I think this would be REALLY slow.
--Rob