Re: [Zope] How to show field names from sql query?

2005-09-20 Thread Dieter Maurer
Thomas Apostolou wrote at 2005-9-19 13:43 +0100:
i use the following to get to show the results from an
sql query.
What are the expresions to show the field names?

The ZSQL method result has a method names returning the
field names.

You can use it in a dtml-let, similar to:

dtml-let
  result=TestODBCEM()
  field_names=result.names()
  
  dtml-in result prefix=row
dtml-in field_names prefix=field
  dtml-var field_item !-- the field name --
  dtml-var expr=_[field_item] !-- its value --
 

-- 
Dieter
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] How to show field names from sql query?

2005-09-20 Thread J Cameron Cooper

Thomas Apostolou wrote:

Hello all,
i use the following to get to show the results from an
sql query.
What are the expresions to show the field names?

table
  dtml-in expr=TestODBCEM(sysDSN=sysDSN, usr=usr,
mypass=mypass, sSQL=sSQL)
dtml-if sequence-even
  tr bgcolor=lightgreen
dtml-else
  tr
/dtml-if
dtml-in sequence-item
  tddtml-var sequence-item/td
/dtml-in
/tr
  /dtml-in

/table


You can ask the Results object 'names()' to get the names of the columns 
of your results. Note you need to ask the results list, not an 
individual result, so you'll need to define TestODBCEM(sysDSN=sysDSN, 
usr=usr, mypass=mypass, sSQL=sSQL) as something so as to ask it for 
names and loop over it later.


--jcc

--
Building Websites with Plone
http://plonebook.packtpub.com/

Enfold Systems, LLC
http://www.enfoldsystems.com
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


[Zope] How to show field names from sql query?

2005-09-19 Thread Thomas Apostolou
Hello all,
i use the following to get to show the results from an
sql query.
What are the expresions to show the field names?

table
  dtml-in expr=TestODBCEM(sysDSN=sysDSN, usr=usr,
mypass=mypass, sSQL=sSQL)
dtml-if sequence-even
  tr bgcolor=lightgreen
dtml-else
  tr
/dtml-if
dtml-in sequence-item
  tddtml-var sequence-item/td
/dtml-in
/tr
  /dtml-in
/table

Thanks in advance.
Thomas.






___ 
Χρησιμοποιείτε Yahoo!; 
Βαρεθήκατε τα ενοχλητικά μηνύματα (spam); Το Yahoo! Mail 
διαθέτει την καλύτερη δυνατή προστασία κατά των ενοχλητικών 
μηνυμάτων http://login.yahoo.com/config/mail?.intl=gr 

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )