You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Mike Chan <yt...@aajc.hku.hk> on 2000/01/21 06:48:52 UTC

usage of SQLProcessor {@var}

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>

but it doesn't work.

Mike


Re: usage of SQLProcessor {@var}

Posted by Donald Ball <ba...@webslingerZ.com>.
On Fri, 21 Jan 2000, Mike Chan wrote:

> thanks a lot, I just forget to place the single quote.
> 
> BTW, how to turn on full debugging?

Read the bit about error handling at

http://xml.apache.org/cocoon/sql.html

Note it would be nice if we could configure this in general higher up in
the XSP food chain, so that we could use standard syntax across all
taglibs.

- donald


Re: usage of SQLProcessor {@var}

Posted by Mike Chan <yt...@aajc.hku.hk>.
thanks a lot, I just forget to place the single quote.

BTW, how to turn on full debugging?

(I'm using Apache 1.3.9, ApacheJServ1.1.3b, Cocoon, Xerces, Xalan on NT)

Best Wishes,

Mike

Donald Ball wrote:

> 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


Re: usage of SQLProcessor {@var}

Posted by Donald Ball <ba...@webslingerZ.com>.
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