cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ralph Skulbörstad <ra...@jak.se>
Subject SV: dynamic query with esql
Date Wed, 29 Jun 2005 13:23:47 GMT
Hi.

One way you can do is to use:

<xsp:logic>
    String yourLocalStringVariable;
</xsp:logic>

and get the value from esql:

...
<esql:row-results>
    <xsp:logic>
        yourLocalStringVariable = <esql:get-string column="rst_child"/>
    </xsp:logic>
</esql:row-results>
...

and use it in the last query:

<esql:query>SELECT ar_tit,id_art FROM dbarticoli
                   WHERE ar_sez =
'<xsp:expr>yourLocalStringVariable</xsp:expr>'   <- Note the ' symbol around
when using strings
</esql:query>


HTH
/Ralph



 -----Ursprungligt meddelande-----
Från: Franco Andrao [mailto:franco.andrao@gruppo4.com]
Skickat: den 29 juni 2005 14:44
Till: users@cocoon.apache.org
Ämne: dynamic query with esql


  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-parame
ter 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