I'm just going by the docs in Zope Help. I haven't used sqltest myself (so far, I usually just write out the queries by hand). According to the docs (reading between the lines a bit), <dtml-sqltest industry_group op=eq type=nb> will look for a Zope variable named "industry_group", and compare it against the value of the column of that name for the row currently being processed, equivalent to: select .... where industry_group='<dtml-var industry_group>' I'm not quite clear about what you want to do. Do you want to retrieve rows where ***any*** of [ticker,company_name,...] are non-empty? If so, your query would be like this: select company_name,ticker,primary_exchange from company_index where ticker <>'' OR company_name <>'' OR industry_group <>'' OR industry_subgroup <>'' OR market_cap <>'' OR market_sector <>'' OR primary_exchange<>'' If this is not what you have in mind, you'd better explain just what you do want. Cheers, Tom P [Jorge O. Martinez]
Hi Thomas:
However, wouldn't that defeat the purpose of sqltest? I mean, precisely I want to be able to only set one (ticker, company_name, etc.), or none, and have sqltest evaluate them, and ignore the ones not set, or that do not exist, and then, have it dynamically create my query based on the one that do exists and is set.
BTW, I used David's suggestion, and that seems to have improved things, as the logic now at least works in the 'test' mode, but I am still not getting it to work with the rest of the code, but there might be some other thing I may have missed there.
Thanks for the tips,
Jorge M.
Thomas B. Passin wrote:
industry_group is supposed to be a variable known to the Zope namespace. If this variable doe snot exist, you would get the error you quote. Make sure you have created the variable and assigned it a value.
Cheers,
Tom P
[Jorge O. Martinez]
Not sure if this is a DB question, or DTML question, so I'm sending it to
the
general Zope list.
I've been banging my head over this relatively simple query, which (if my understanding of the dtml-sqltest tag is correct), should be fine. The
idea is
simple, get 3 columns from company_index, and display the results, if
there's
further constrains set (like ticker, company_name, etc.), taylor the query accordingly:
select company_name,ticker,primary_exchange from company_index <dtml-sqlgroup where> <dtml-sqltest ticker op=eq type=nb> <dtml-sqltest company_name op=like type=nb> <dtml-sqltest industry_group op=eq type=nb> <dtml-sqltest industry_subgroup op=eq type=nb> <dtml-sqltest market_cap op=eq type=nb> <dtml-sqltest market_sector op=eq type=nb> <dtml-sqltest primary_exchange op=eq type=nb> </dtml-sqlgroup>
but it's not happy. It keeps displaying errors like this: