[Zope-DB] Calling SQL Query in DTML Method with a string argument

Garry Saddington garry at schoolteachers.co.uk
Mon Jul 28 12:20:03 EDT 2008


On Monday 28 July 2008 15:59, Matylda Sawicka wrote:
> Hello,
> I am a fresh Zope Explorer. I was trying to call an SQL Query that requires
> an argument in a DTML Method that would be called with an argument passed
> in the URL. The Query looks more or less like this:
>
> SELECT Uni_Name,
>        Uni_Latitude,
>        Uni_Longitude
> FROM universities
> WHERE Uni_Code = <dtml-sqlvar givenCode type="string"> AND
>       Uni_Latitude != NULL
>
> whilst the DTML Method consists of:
TRY:
> <markers>
> <dtml-in expr="uniSingleByCode(givenCode=_['uni_id'])">
> <mrk nm="<dtml-var Uni_Name>" lat="<dtml-var Uni_Latitude>" lng="<dtml-var
> Uni_Longitude>"/>
> </dtml-in>
> </markers>
or just let the ZSQL get the argument from the REQUEST:
>> <markers>
> <dtml-in uniSingleByCode>
> <mrk nm="<dtml-var Uni_Name>" lat="<dtml-var Uni_Latitude>" lng="<dtml-var
> Uni_Longitude>"/>
> </dtml-in>
> </markers>
HTH
regards
Garry


More information about the Zope-DB mailing list