[Zope] [NEWBIE] Unambiguous expressions in Z SQL methods

Biju Chacko biju@exocore.com
20 Mar 2002 16:48:37 +0530


Hi,

I have a legacy database which uses an internal convention of naming the
primary key of a table as 'code'. When executing queries which include
joins, it is necessary to add a table name prefix in order to make them
unambiguous. For example:

SELECT foo.*, bar.desc
FROM foo
    INNER JOIN bar ON foo.bar = bar.code
WHERE foo.code = some_value

I created a Z SQL Method called listFoo thus:

-8<------

Parameter: foo.code

SELECT foo.*, bar.desc
FROM foo
    INNER JOIN bar ON foo.bar = bar.code
<dtml-sqlgroup where>
    <dtml-sqltest foo.code op="eq" type="int">
</dtml-sqlgroup>

-8<-------

This works fine when I test it. However, I'm having a bit of trouble
calling from my dtml document. I'm trying to use a line like:

<dtml-in expr="listFoo(foo.code=code)">

which bombs (naturally).

So how do I go about this? I'm sorry if this is a FAQ, I'm a Zope newbie
-- I've been using it precisely 5 days.

TIA

-- Biju

-- 
-------------------------------------------------
Biju Chacko        | biju@exocore.com (work)            
Exocore Consulting | biju_chacko@yahoo.com (play)
Bangalore, India   | http://www.exocore.com
-------------------------------------------------
You shouldn't wallow in self-pity.  But it's OK to put your feet in it
and swish them around a little.
		-- Guindon