ZSQL Methods are a zope code object similar to a DTMLMethod or Python Scripts except specialized for use with relational databases; they are the easiest way to connect Zope to a RDBMS. They contain SQL and DTML commands and have an associated [database connection]?.
- http://www.plope.com/Books/2_7Edition/RelationalDatabases.stx#1-8
- in the Zope Book
- Z SQL Methods User's Guide
- last updated in 2000
- http://www.bris.ac.uk/is/services/software/packages/zope/
- more tips
- Cataloging SQL Data and Almost Anything Else
Multiple SQL Statements in one Z SQL Method -- Fri, 11 Mar 2005 04:43:05 -0800 reply
For ZMySQLDA at least you must seperate your sql statements with <dtml-var sql_delimiter> not a ;
... -- Fri, 11 Mar 2005 05:35:24 -0800 reply
you should always use <dtml-var sql_delimiter>, but not all DB-adapters understand sql_delimiter. only the last sql statement in such a sequence can be a SELECT statement.
how to query with optional arguments --simon, Tue, 25 Oct 2005 11:43:05 -0700 reply
I had no luck with the advice in these docs, until I tried this incantation:
<params>number firstname lastname</params> select * from table <dtml-sqlgroup required where> <dtml-sqltest number op=eq type=string optional> <dtml-and> <dtml-sqltest firstname op=eq type=string optional> <dtml-and> <dtml-sqltest lastname op=eq type=string optional> </dtml-sqlgroup>
This accepts one or more of the number, firstname, lastname arguments. Note python's optional argument declaration style is not used in params, and dtml-if is not used (I don't know why this doesn't work):
<dtml-if firstname> and <dtml-sqlvar firstname type=string> </dtml-if>