<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000"
 style="font-size: 10pt; color: rgb(0, 0, 0); font-family: Arial;">
Charlie Clark wrote:<br>
<blockquote cite="mid20040629115426.2252.7@wonderland.1088491425.fake"
 type="cite">
  <pre wrap="">On 2004-06-29 at 10:22:14 [+0200], "Smith, Neil (Worcester)" 
<a class="moz-txt-link-rfc2396E" href="mailto:Neil.Smith@npower.com">&lt;Neil.Smith@npower.com&gt;</a> wrote:
  </pre>
  <blockquote type="cite">
    <pre wrap="">The point of the dtml-sqlgroup and dtml-sqltest is surely to provide a nice
way of handling the case where you don't pass in the parameter, so it
doesn't render the WHERE, AND, = etc.  And it does this quite well.
    </pre>
  </blockquote>
  <pre wrap=""><!---->
Maybe it does. I've never found cause to use it and scratched my head a lot 
trying to look at it. I'd hate to maintain such stuff something which Ian 
Bicking seems to complain about.
 
  </pre>
</blockquote>
<br>
I've found cause to use this in almost every other ZSQL method I write.
For me, it's one of ZSQL Methods most usefull features. <br>
<blockquote cite="mid20040629115426.2252.7@wonderland.1088491425.fake"
 type="cite">
  <pre wrap="">
I think what might be the biggest problem is the lack of good examples on 
this. The stuff in Zope book does not seem to me to be written with real 
world experience so maybe you've got a concrete example with the resultant 
SQL for us to discuss?

  </pre>
</blockquote>
<br>
<br>
I can give an example. I have a report where users can use various
items on a form to narrow down the rows returned. Any criteria left
blank don't affect the amount of rows returned. Here are the arguments:<br>
<br>
start_date end_date programme_title programme_ar seg event_description
event_ar c_number event_type duration tc_in tc_out slide_no cf_no
clock_no notes<br>
<br>
and here's the ZSQL method<br>
<br>
SET DATEFORMAT dmy<br>
SELECT<br>
&nbsp; e.event_id,<br>
&nbsp; e.tx_date,<br>
&nbsp; e.programme_title,<br>
&nbsp; e.programme_ar,<br>
&nbsp; ar1.short_name 'prog_aspect',<br>
&nbsp; e.seg,<br>
&nbsp; e.event_description,<br>
&nbsp; e.event_ar,<br>
&nbsp; ar2.short_name 'event_aspect',<br>
&nbsp; e.c_number,<br>
&nbsp; e.event_type,<br>
&nbsp; et.note 'type',<br>
&nbsp; e.duration,<br>
&nbsp; e.tc_in,<br>
&nbsp; e.tc_out,<br>
&nbsp; e.slide_no,<br>
&nbsp; e.cf_no,<br>
&nbsp; e.clock_no,<br>
&nbsp; e.notes <br>
FROM <br>
&nbsp;events e<br>
LEFT JOIN aspect_ratios ar1 ON<br>
&nbsp; e.programme_ar = ar1.ar_id<br>
LEFT JOIN aspect_ratios ar2 ON<br>
&nbsp; e.event_ar = ar2.ar_id<br>
LEFT JOIN event_types et ON<br>
&nbsp; e.event_type = et.event_type_id<br>
&lt;dtml-sqlgroup where&gt;<br>
&nbsp;&lt;dtml-sqltest start_date op="ge" type="nb" column="tx_date"
optional&gt;<br>
&nbsp;&lt;dtml-and&gt;<br>
&nbsp;&lt;dtml-sqltest end_date op="le" type="nb" column="tx_date"
optional&gt;<br>
&nbsp;&lt;dtml-and&gt;<br>
&nbsp;&lt;dtml-sqltest programme_title op="like" type="nb" optional&gt;<br>
&nbsp;&lt;dtml-and&gt;<br>
&nbsp;&lt;dtml-sqltest seg op="like" type="nb" optional&gt;<br>
&nbsp;&lt;dtml-and&gt;<br>
&nbsp;&lt;dtml-sqltest event_description op="like" type="nb" optional&gt;<br>
&nbsp;&lt;dtml-and&gt;<br>
&nbsp;&lt;dtml-sqltest event_ar op="eq" type="int" optional&gt;<br>
&nbsp;&lt;dtml-and&gt;<br>
&nbsp;&lt;dtml-sqltest programme_ar op="eq" type="int" optional&gt;<br>
&nbsp;&lt;dtml-and&gt;<br>
&nbsp;&lt;dtml-sqltest c_number op="like" type="nb" optional&gt;<br>
&nbsp;&lt;dtml-and&gt;<br>
&nbsp;&lt;dtml-sqltest event_type op="eq" type="int" optional&gt;<br>
&nbsp;&lt;dtml-and&gt;<br>
&nbsp;&lt;dtml-sqltest duration op="like" type="nb" optional&gt;<br>
&nbsp;&lt;dtml-and&gt;<br>
&nbsp;&lt;dtml-sqltest tc_in op="like" type="nb" optional&gt;<br>
&nbsp;&lt;dtml-and&gt;<br>
&nbsp;&lt;dtml-sqltest tc_out op="like" type="nb" optional&gt;<br>
&nbsp;&lt;dtml-and&gt;<br>
&nbsp;&lt;dtml-sqltest slide_no op="like" type="nb" optional&gt;<br>
&nbsp;&lt;dtml-and&gt;<br>
&nbsp;&lt;dtml-sqltest clock_no op="like" type="nb" optional&gt;<br>
&lt;/dtml-sqlgroup&gt;<br>
<br>
<br>
<br>
And that's a simple example. I've had to do similar things before
outside of Zope and it wasn't pretty, in Zope it was very
straightforward.<br>
<br>
<br>
cheers<br>
<br>
Scot<br>
<FONT SIZE=3><BR>
<BR>
</FONT>
</body>
</html>