Hi Thomas,

The ESQL logicsheet (a least in 2.1.4) doesn't use other code than <esql:*> elements in a 
<esql:execute-query>.
Try to determine your query before getting in the execute-query. Your code will look 
simpler :

<xsp:logic>
    String query = null;
    if (cond1) {
        query = "";
    } else if (cond2) {
        query = "";
    } else ...
</xsp:logic>
<esql:execute-query>
    <esql:query><xsp:expr>query</xsp:expr></esql:query>
    ....
<esql:execute-query>

--
Olivier Billard

Thomas Zehetbauer wrote:
Hi,

I would like to use the same <esql:results> block for currently three
different queries that return the same fields but use distinct
conditions and parameters. I tried to use a <xsp:logic> block for
choosing the <esql:query> but I only get an error message. Is this kind
of logic possible with XSP/logicsheets?

Tom



------------------------------------------------------------------------

<?xml version="1.0" encoding="UTF-8"?>
<xsp:page
                language="java"
                xmlns:esql="http://apache.org/cocoon/SQL/v2";
                xmlns:xsp-request="http://apache.org/xsp/request/2.0";
                xmlns:xsp="http://apache.org/xsp";>
        <page>
                <title>German/English Dictionary</title>
                <stylesheet>css/Dictionary.css</stylesheet>
                <content>
                        <form>
                                <table class="query">
                                        <tr class="query">
                                                <td class="queryCaption">Query</td>
                                                <td class="queryValue"><input class="queryValue" 
name="query"/></td>
                                        </tr>
                                        <tr class="direction">
                                                <td 
class="directionCaption">Direction</td>
                                                <td class="directionValue">
                                                        <select class="directionValue" 
name="direction">
                                                                <option 
value="BOTH">both</option>
                                                                <option value="ENGLISH">German 
-&gt; English</option>
                                                                <option value="GERMAN">English 
-&gt; German</option>
                                                        </select>
                                                </td>
                                        </tr>
                                        <tr class="submit">
                                                <td class="submit" colspan="2"><input class="submit" 
type="submit" value="Go!"/></td>
                                        </tr>
                                </table>
                        </form>
                        <xsp:logic>
                        String query = <xsp-request:get-parameter name="query"/>;
                        String direction = <xsp-request:get-parameter 
name="direction"/>;
                        if (query != null &amp;&amp; direction != null) {
                                <esql:connection>
                                        <esql:pool>Dictionary</esql:pool>
                                        <esql:execute-query>
                                                <xsp:logic>
                                                if ("ENGLISH".equals(direction)) {
                                                        <esql:query>SELECT English,German FROM GermanEnglish WHERE 
German REGEXP <esql:parameter><xsp:expr>query</xsp:expr></esql:parameter> ORDER BY 
English</esql:query>
                                                } else if ("GERMAN".equals(direction)) 
{
                                                        <esql:query>SELECT English,German FROM GermanEnglish WHERE 
English REGEXP <esql:parameter><xsp:expr>query</xsp:expr></esql:parameter> ORDER BY 
English</esql:query>
                                                } else {
                                                        <esql:query>SELECT English,German FROM GermanEnglish WHERE English REGEXP 
<esql:parameter><xsp:expr>query</xsp:expr></esql:parameter> OR German REGEXP 
<esql:parameter><xsp:expr>query</xsp:expr></esql:parameter> ORDER BY English</esql:query>
                                                }
                                                </xsp:logic>
                                                <esql:results>
                                                        <table class="result">
                                                                <tr 
class="resultHeader">
                                                                        <td 
class="resultHeaderEnglish">English</td>
                                                                        <td 
class="resultHeaderGerman">German</td>
                                                                </tr>
                                                                <esql:row-results>
                                                                        <tr 
class="result">
                                                                                <td 
class="resultEnglish"><esql:get-string column="English"/></td>
                                                                                <td 
class="resultGerman"><esql:get-string column="German"/></td>
                                                                        </tr>
                                                                </esql:row-results>
                                                        </table>
                                                </esql:results>
                                        </esql:execute-query>
                                </esql:connection>
                        }
                        </xsp:logic>
                </content>
        </page>
</xsp:page>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to