cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rudi Strasser <>
Subject Re: binding params in dynamic queries in ESQL
Date Sun, 07 Mar 2004 14:55:32 GMT
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"?>

   <die-data xmlns:cinclude="">
          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=""/>;
           <util:param name="uri">cocoon:/paraminfo?parname=<xsp:expr>parname</xsp:expr></util:param>

            <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 
                                     product~'<xsp:expr>product</xsp:expr>' <xsp:expr>suffix</xsp:expr>

                               order by label,tag
                    if (  <esql:get-float column="parameter"/> != 0 )
        	     	    	 <label><esql:get-string column="label"/></label>
		     	    	 <tag><esql:get-string column="tag"/></tag>
                     	    	    <xsp:attribute name="name"><xsp:expr>parname</xsp:expr></xsp:attribute>
                     	          <esql:get-float column="parameter"/>

I hope I am not totally out of context.

> 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:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message