cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Donald Ball <ba...@webslingerZ.com>
Subject Re: C2: recommended method for accessing Database, esp. for nested queries?
Date Fri, 15 Jun 2001 18:45:11 GMT
On Wed, 13 Jun 2001, [iso-8859-1] Götz Botterweck wrote:

> I'm already using the ESQL. Now I'd like to do nested queries. Somewhat
> like that
>
> QUERY
> 	retrieve departments
> 	FOR EACH department d
> 		retrieve all members of d
> 	/FOR EACH
> /QUERY
>
> I've seen the file ../docs/samples/sql/sql-page.xml with the
> <anchestor-value ... > tag. Is something similar possible with ESQL?

yes:

<?xml version="1.0"?>

<?cocoon-process type="xsp"?>

<xsp:page
  xmlns:xsp="http://www.apache.org/1999/XSP/Core"
  xmlns:esql="http://apache.org/cocoon/SQL/v2"
>

<page>

<esql:connection>
  <esql:driver>org.postgresql.Driver</esql:driver>
  <esql:dburl>jdbc:postgresql://localhost/test</esql:dburl>
  <esql:username>test</esql:username>
  <esql:password>test</esql:password>
  <esql:execute-query>
    <esql:query>select id,name from department_table</esql:query>
    <esql:results>
      <header>header info</header>
      <esql:row-results>
        <department>
          <id><esql:get-int column="id"/></id>
          <name><esql:get-string column="name"/></name>
          <esql:execute-query>
            <esql:query>select name from user_table where department_id = <esql:parameter
type="int"><esql:get-int ancestor="1" column="id"/></esql:parameter></esql:query>
            <esql:results>
              <esql:row-results>
                <user><esql:get-string column="name"/></user>
              </esql:row-results>
            </esql:results>
            <esql:no-results>
              <user>No employees</user>
            </esql:no-results>
          </esql:execute-query>
        </department>
      </esql:row-results>
      <footer>footer info</footer>
    </esql:results>
  </esql:execute-query>
</esql:connection>

</page>

</xsp:page>


---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <cocoon-users-unsubscribe@xml.apache.org>
For additional commands, e-mail: <cocoon-users-help@xml.apache.org>


Mime
View raw message