You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Torsten Curdt <tc...@dff.st> on 2000/07/10 17:22:48 UTC
built sql query
I know now how to do and display a sql query with cocoon.
But can anyone show me a good way to do a built query?
I mean a query that is modified by the parameters passed
to the page (a very common task)
something like:
show.xml?id=50 -> select * from sometable where tableid=50
actually the question is: how can I pass my java built
sql string to the sql processor?
--
Torsten
Re: built sql query
Posted by Hans-Guenter Stein <Ha...@siteos.de>.
try something like:
...
xmlns:request="http://www.apache.org/1999/XSP/Request"
...
<xsp:logic>
String theID[] = <request:get-parameter-values name="id"/>;
QueryString = "select * from sometable where tableid=" + theID[0];
result = myDBMethod.execQuery(QueryString);
...
</xsp:logic>
Torsten Curdt wrote:
> I know now how to do and display a sql query with cocoon.
> But can anyone show me a good way to do a built query?
>
> I mean a query that is modified by the parameters passed
> to the page (a very common task)
>
> something like:
>
> show.xml?id=50 -> select * from sometable where tableid=50
>
> actually the question is: how can I pass my java built
> sql string to the sql processor?
> --
> Torsten
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org
Re: built sql query
Posted by Brian P Millett <bp...@ec-group.com>.
> Torsten Curdt wrote:
>
>> I know now how to do and display a sql query with cocoon.
>> But can anyone show me a good way to do a built query?
>>
>> I mean a query that is modified by the parameters passed
>> to the page (a very common task)
>>
>> something like:
>>
>> show.xml?id=50 -> select * from sometable where tableid=50
>>
>> actually the question is: how can I pass my java built
>> sql string to the sql processor?
>
Must be a few ways to do this. Here is my .02$ for a query (http://foo.com/test.xml?lastName='foo')
<sql:execute-query>
<sql:driver>oracle.jdbc.driver.OracleDriver</sql:driver>
<sql:dburl>jdbc:oracle:thin:@localhost:1521:dldf</sql:dburl>
<sql:username>foo</sql:username>
<sql:password>foo</sql:password>
<sql:skip-rows>0</sql:skip-rows>
<sql:max-rows>50</sql:max-rows>
<sql:null-indicator>y</sql:null-indicator>
<sql:count-attribute>BOB</sql:count-attribute>
<sql:doc-element>ROWSET</sql:doc-element>
<sql:row-element>ROW</sql:row-element>
<sql:tag-case>preserve</sql:tag-case>
<sql:id-attribute>ID</sql:id-attribute>
<sql:query>
SELECT *
FROM EMPLOYEE
WHERE last_name = <request:get-parameter name="lastName"/>
</sql:query>
</sql:execute-query>
--
Brian Millett
Enterprise Consulting Group "Shifts in paradigms
(314) 205-9030 often cause nose bleeds."
bpm@ec-group.com Greg Glenn
Re: built sql query
Posted by Mark Washeim <es...@canuck.com>.
on 10/7/00 5:22 pm, Torsten Curdt at tcurdt@dff.st wrote:
> I know now how to do and display a sql query with cocoon.
> But can anyone show me a good way to do a built query?
>
> I mean a query that is modified by the parameters passed
> to the page (a very common task)
>
> something like:
>
> show.xml?id=50 -> select * from sometable where tableid=50
>
> actually the question is: how can I pass my java built
> sql string to the sql processor?
> --
> Torsten
<?xml version="1.0" encoding="ISO-8859-1"?>
<?cocoon-process type="xsp"?>
<xsp:page
language="java"
xmlns:sql="http://www.apache.org/1999/SQL"
xmlns:xsp="http://www.apache.org/1999/XSP/Core"
xmlns:request="http://www.apache.org/1999/XSP/Request"
>
<page title="SQL Search Results">
<xsp:logic>
String where = "";
where = "'" + request.getParameter("someParam") + "'";
</xsp:logic>
<sql:execute-query>
<sql:driver>driver</sql:driver>
<sql:dburl>url</sql:dburl>
<sql:username>user</sql:username>
<sql:password>pass</sql:password>
<sql:doc-element>RANK</sql:doc-element>
<sql:row-element>ROW</sql:row-element>
<sql:tag-case>upper</sql:tag-case>
<sql:max-rows>10</sql:max-rows>
<sql:null-indicator>yes</sql:null-indicator>
<sql:id-attribute>ID</sql:id-attribute>
<sql:id-attribute-column>ID</sql:id-attribute-column>
<sql:query>select * from TABLE where COLUMN =
<xsp:expr>where</xsp:expr> </sql:query>
<sql:count-attribute>count</sql:count-attribute>
</sql:execute-query>
</page>
</xsp:page>
you could also do
<sql:query>select * from TABLE where COLUMN = <request:get-parameter
name="someParam" as="string"/></sql:query>
--
Mark (Poetaster) Washeim
'On the linen wrappings of certain mummified remains
found near the Etrurian coast are invaluable writings
that await translation.
Quem colorem habet sapientia?'
Evan S. Connell
Re: Oracle persistence
Posted by Mike Engelhart <me...@earthtrip.com>.
on 7/10/00 2:19 PM, Martin O. Mauri at mmauri@vates.com wrote:
> Hi everybody:
>
> How do I configure my jboss.conf file to set the Oracle 8.0.5 JDBC driver?
>
> And another one...I'm trying to set a CMP. Do I have to configure some
> jaws.xml in my deployment descriptor?
>
> Thanks in advance,
>
> Maritn O. Mauri
wrong list...
Mike
Oracle persistence
Posted by "Martin O. Mauri" <mm...@vates.com>.
Hi everybody:
How do I configure my jboss.conf file to set the Oracle 8.0.5 JDBC driver?
And another one...I'm trying to set a CMP. Do I have to configure some
jaws.xml in my deployment descriptor?
Thanks in advance,
Maritn O. Mauri
Re: built sql query
Posted by Donald Ball <ba...@webslingerZ.com>.
On Mon, 10 Jul 2000, Torsten Curdt wrote:
> I know now how to do and display a sql query with cocoon.
> But can anyone show me a good way to do a built query?
>
> I mean a query that is modified by the parameters passed
> to the page (a very common task)
>
> something like:
>
> show.xml?id=50 -> select * from sometable where tableid=50
>
> actually the question is: how can I pass my java built
> sql string to the sql processor?
you want to use the sql logicsheet. read
http://xml.apache.org/cocoon/sqltaglib.html. an example:
<sql:execute-query>
...
<sql:query>
select * from sometable where tableid=<request:get-parameter name="id"/>
</sql:query>
</sql:execute-query>
for your own java built string:
<sql:execute-query>
...
<sql:query>
select * from sometable where tableid=<xsp:expr>myMethod()</xsp:expr>
</sql:query>
</sql:execute-query>
- donald