cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Donald Ball <ba...@webslingerZ.com>
Subject Re: usage of SQLProcessor {@var}
Date Fri, 21 Jan 2000 06:17:51 GMT
On Fri, 21 Jan 2000, Mike Chan wrote:

> Hi All,
> 
> Anyone have try out the parameter subsitution {@var} feature of Cocoon
> 1.6 SQL Processor?  Is there any real example I can learn from?
> 
> Actually, I've try loading my XML page like
> http://localhost/sql/database-page.xml?var=123
> 
> where database-page.xml contains the following query:
> 
>  <query connection="test_connection" doc-element="">
>   select col1, col2, col3 from table1 where col1={@var}
>  </query>

Offhand, I'd guess that col1 is a column that requires constant values to
be enclosed by single quotes. Otherwise turn on full debugging and let me
know what you get.

Perhaps a better alternative would be to use the XSP Request taglib. I
think you would do it by adding a XSP process pass right before the SQL
process pass, add these namespaces to your document root element:

xmlns:xsp="http://www.apache.org/1999/XSP/Core"
xmlns:request="http://www.apache.org/1999/XSP/Request"

and getting the request parameter like this:

<query ...>
 select col1, col2, col3 from table1 where col1 =
 <request:get-parameter name="var"/>
</query>

Note that the request:get-parameter tag may still need the single quotes.

This is highly likely the way that SQL (and other) processors will access
runtime information in the future.

Note I'm not an XSP expert yet so Ricardo or Stefano will need to chime in
here if I got the syntax or methodology wrong.

- donald


Mime
View raw message