Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Zope: DB

Calling SQL Query in DTML Method with a string argument

 

 

Zope db RSS feed   Index | Next | Previous | View Threaded


vial.of.black.dye at gmail

Jul 28, 2008, 7:59 AM

Post #1 of 2 (1609 views)
Permalink
Calling SQL Query in DTML Method with a string argument

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:
<markers>
<dtml-in expr="uniSingleByCode(givenCode='<dtml-var uni_id>')">
<mrk nm="<dtml-var Uni_Name>" lat="<dtml-var Uni_Latitude>" lng="<dtml-var
Uni_Longitude>"/>
</dtml-in>
</markers>


If I replace the <dtml-var uni_id> with an existing uni code, query works,
but as it is, I get an empty XML (well, just <markers></markers> appear).
I am perfectly aware of the fact that the mistake I make must be trivial,
but nevertheless I'd like to ask for some enlightment.
Best regards,
Olia


garry at schoolteachers

Jul 28, 2008, 9:20 AM

Post #2 of 2 (1508 views)
Permalink
Re: Calling SQL Query in DTML Method with a string argument [In reply to]

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
_______________________________________________
Zope-DB mailing list
Zope-DB[at]zope.org
http://mail.zope.org/mailman/listinfo/zope-db

Zope db RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.