On Saturday 06 March 2004 06:36, R Hunt wrote:
> Thanks for everyone's advice on this topic.  It seems that the general
> consensus is that one should use <esql:parameter> to bind parameters, but
> it can't be done when building a dynamic query.

I am not 100% sure if you basically want to assemble the query dynamically. If that is 
the case I did that successfully in the following xsp:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsp:page 
   xmlns:xsp="http://apache.org/xsp"; 
   xmlns:xsp-request="http://apache.org/xsp/request/2.0"; 
   xmlns:esql="http://apache.org/cocoon/SQL/v2";
   xmlns:util="http://apache.org/xsp/util/2.0";
   language="java">

   <die-data xmlns:cinclude="http://apache.org/cocoon/include/1.0";>
      <xsp:logic>
          String parname = <xsp-request:get-parameter name="parname" 
default="myparameter"/>;
          String table = <xsp-request:get-parameter name="table" default="mytable"/>;

          String label = <xsp-request:get-parameter name="label" default="lot"/>;
          String tag = <xsp-request:get-parameter name="tag" default="testplan"/>;

          String lot = <xsp-request:get-parameter name="lot" default="mylot"/>;
          String wafer = <xsp-request:get-parameter name="wafer" default="(.*)"/>;
          
          String product = <xsp-request:get-parameter name="product" 
default="defaultproduct"/>;
          String testplan = <xsp-request:get-parameter name="testplan" 
default="default-testplan"/>;
          String suffix = <xsp-request:get-parameter name="suffix" default=""/>;
          
      </xsp:logic>
      <parameter-info>
         <util:include-source>
           <util:param 
name="uri">cocoon:/paraminfo?parname=<xsp:expr>parname</xsp:expr></util:param>
         </util:include-source>
      </parameter-info>
      <esql:connection>
         <esql:pool>jdp</esql:pool>

         <esql:execute-query>
            <esql:query>select <xsp:expr>label</xsp:expr> as label,
                               <xsp:expr>tag</xsp:expr> as tag,
                               abs(<xsp:expr>parname</xsp:expr>) as parameter  
                               from <xsp:expr>table</xsp:expr> 
                               where lot~'<xsp:expr>lot</xsp:expr>' and 
                                     wafer~'<xsp:expr>wafer</xsp:expr>' and 
                                     testplan~'<xsp:expr>testplan</xsp:expr>' and
                                     product~'<xsp:expr>product</xsp:expr>' 
<xsp:expr>suffix</xsp:expr> 
                               order by label,tag
                                     
            </esql:query>
            <esql:results>
               <esql:row-results>
                  <xsp:logic>
                    if (  <esql:get-float column="parameter"/> != 0 )
                     {
                       <xsp:content>
                           <record>
                                 <label><esql:get-string column="label"/></label>
                                 <tag><esql:get-string column="tag"/></tag>
                                 <parameter>
                                    <xsp:attribute 
name="name"><xsp:expr>parname</xsp:expr></xsp:attribute>
                                  <esql:get-float column="parameter"/>
                                 </parameter>
                           </record>
                       </xsp:content>
                     }
                  </xsp:logic>
               </esql:row-results>
            </esql:results>
         </esql:execute-query>
      </esql:connection>
   </die-data>
</xsp:page>


I hope I am not totally out of context.
/Rudi


> Thanks.
>
> At 06:41 PM 3/5/2004 +0100, you wrote:
> >You are mixing things up. :)
> >Better have a look into the examples.
>
> Can you recommend some examples that show a dynamically built query that
> uses <esql:parameter>?
>
> >What you want to do here is build the
> >clause ...which has nothing to do with
> >esql! Drop the paramopen/close stuff
> >and you are fine.
>
> Doesn't the <esql:parameter> tags belong in the where clause?
>
> >Always(!!) use esql:parameter to insert
> >dynamic values - or at least never pass
> >request values directly.
>
> Yes,  I would like to!  But how can I do it with a dynamically built query?
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to