cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mike Lenyon" <m...@lenyon.com>
Subject nested query with esql
Date Mon, 05 May 2003 14:12:56 GMT
hi all,

first, my environment:
cocoon 2.0.4
tomcat 4.0.4
jdk 1.3.1_02
mm.mysql driver 2.0.11

i only began working with cocoon about a week ago, so i'm definitely a newbie.  i'm trying
to work with a nested query but it's producing an error in the generated java code.  here's
my xsp code:

<xsp:page
    language="java"
    xmlns:xsp="http://apache.org/xsp"
    xmlns:esql="http://apache.org/cocoon/SQL/v2"
    >
    
        <esql:connection>
            <esql:pool>quotescape</esql:pool>

            <esql:execute-query>

                <esql:query>
                    SELECT categories_id, categories_name
                        FROM categories_description
                </esql:query>

                <esql:results>
                    <product-categories>
                        <esql:row-results>
                            <category>
                                <id><esql:get-long column="categories_id"/></id>
                                <name><esql:get-string column="categories_name"/></name>

                                <!-- get the number of products in the category -->
                                <esql:execute-query>
                                    <esql:query>
                                        SELECT COUNT(*) AS count FROM products, products_to_categories
                                            WHERE products.products_id = products_to_categories.products_id
                                                AND categories_id = 
                                                    <esql:parameter type="long">
                                                        <esql:get-long ancestor="1" column="categories_id"/>
                                                    </esql:parameter>
                                    </esql:query>

                                    <esql:results>
                                        <esql:row-results>
                                            <count><esql:get-int column="count"/></count>
                                        </esql:row-results>
                                    </esql:results>
                                </esql:execute-query>
                            </category>
                        </esql:row-results>
                    </product-categories>
                </esql:results>

            </esql:execute-query>
        </esql:connection>
</xsp:page>

and here's the relevant snippet from the exception in error.log:

org.apache.cocoon.components.language.LanguageException: Error compiling index_productcategories_xsp:
Line 432, column 56:  unclosed character literal
Line 432, column 55:  illegal start of expression
Line 434, column 55:  unclosed character literal

and here are the relevant lines in the generated java:

    _esql_query = new EsqlQuery( _esql_connection, String.valueOf(
      ""
      
              
                + "                                         SELECT COUNT(*) AS count FROM
products, products_to_categories                                             WHERE products.products_id
= products_to_categories.products_id                                                 AND categories_id
=                                                      "
              
              
                + "?"
              
                + "                                     "
              ) );

    

    try {
      
            _esql_query.prepareStatement();
          _esql_query.getPreparedStatement().setLong(1,"
                                                        
                                                    ");
      
            _esql_query.execute();

i've search through the archives and noticed a few cases where people were having similar
problems, but i didn't see any resolutions.  i also saw a post that seemed to mention a bug
dealing with prepared statements, but i'm not sure.

thanks in advance for your help!

Mike Lenyon

Mime
View raw message