cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Franco Andrao <franco.and...@gruppo4.com>
Subject dynamic query with esql
Date Wed, 29 Jun 2005 12:44:01 GMT
Hi,
I'm trying to pass variables from the results of a query to another  
query in the same xsp page: this is the code

<?xml version="1.0"?>

<xsp:page language="java"
           xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
           xmlns:xsp="http://apache.org/xsp"
           xmlns:esql="http://apache.org/cocoon/SQL/v2"
           xmlns:xsp-request="http://apache.org/xsp/request/2.0">

<text>
     <xsl:param name="id_rst"/>

     <esql:connection>
         <esql:pool>teosoficaDB</esql:pool>
         <xsl:if test="$id_rst">
             <esql:execute-query>
             <esql:query>SELECT rst_child FROM relstruttura
                         WHERE id_rst=<esql:parameter><xsp- 
request:get-parameter name="id_rst"/></esql:parameter>
             </esql:query>
             <esql:results>
                 <esql:row-results>
                     <esql:get-string column="rst_child"/>  <!-- this  
is the value I want to use below in the page -->
                 </esql:row-results>
             </esql:results>
             </esql:execute-query>
             <esql:execute-query>
                 <esql:query>SELECT st_tit,id_rst FROM  
dbstruttura,relstruttura
                         WHERE  
dbstruttura.id_sez=relstruttura.rst_child AND
                         rst_parent=<esql:parameter><xsp-request:get- 
parameter name="id_rst"/></esql:parameter>
                 </esql:query>
             <esql:results>
                     <esql:row-results>
                         <esql:get-string column="st_tit"/>
                     </esql:row-results>
             </esql:results>
             <esql:no-results>
                 <esql:execute-query>
                 <esql:query>SELECT ar_tit,id_art FROM dbarticoli
                             WHERE ar_sez=  <!-- PARAM!! here the  
value of column rst_child of the first query -->
                 </esql:query>
                 <esql:results>
                     <esql:row-results>
                         <esql:get-string column="ar_tit"/>
                     </esql:row-results>
                 </esql:results>
                 </esql:execute-query>
             </esql:no-results>
             </esql:execute-query>
         </xsl:if>
     </esql:connection>
</text>
</xsp:page>

The code is working if I use test values for the last query but I  
don't know how to set a local variable with the value of the esql:get- 
string ....


Thank for your suggestions



:-)Franco Andrao
franco.andrao@gruppo4.com


Mime
View raw message