[Zope] how to get the fields returned SQL method

Curtis Maloney curtis@umd.com.au
Fri, 24 Mar 2000 11:43:08 +1100


On Fri, 24 Mar 2000, Eric BARROCA wrote:
> Hello,
> 
> I'm trying to get a list of fields returned by a dynamic SQL query.
> I've found a howto telling me to write something like :
> 	<dtml-in SQL.names>
> 	<dtml-var sequence-item>
> 	</dtml-in>
> But it doesn't work : I get the error "Attribute Error : names".
> I've tried with .items, .keys and .fields too.
> 
> I'd like to do the same for an LDAP query.
> 
>
> Any idea ? I think it's very useful and that an easy way exists but I
> can't find it.
> 
>

Well, since the SQL will return a list, firsly you would have to index it...
also, .keys et al are Python stuff, so...(untested)

<dtml-in "SQL[0].keys()">

might be more what you're looking for.  Or...

<dtml-in SQL>
  <dtml-in "keys()">
    <dtml-var sequence-item>
  </dtml-in>
</dtml-in>


should iterate through the keys of each line of the returned table.

> Thanks,
> 
> EB.
-- 
Have a better one,
	Curtis.

<dtml-var standard_work_disclaimer>