You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Hiloliddin Karimov <HK...@central.nbu.com> on 2002/05/15 18:05:48 UTC

DatabaseSelectAction, get results

Hi,

I try use DatabaseSelectAction for selection. I have searched in the
archive, but I haven't found solution, please help.
1. SELECT
If I use key in form:
<table name="users">
  <keys>
    <key param="username" dbcol="username" type="string" mode="manual"/>
  </keys>
  <values>
    <value param="balance" dbcol="balance" type="double"/>
    <value param="status" dbcol="status" type="string"/>
  </values>
</table>
SQL is: SELECT username, balance, status FROM users WHERE username = ?
If I want select all, I try:
<table name="users">
  <values>
    <value param="username" dbcol="username" type="string"/>
    <value param="balance" dbcol="balance" type="double"/>
    <value param="status" dbcol="status" type="string"/>
  </values>
</table>
then SQL is: SELECT username, balance, status FROM users WHERE
and error: unexpected end of SQL command.
why DatabaseSelectAction still use WHERE?

2. How can I get results? 
I see in the "Request logicsheet elements" I can get some more results by
use:
<xsp-request:get-parameter-values name="username"/> isn't it?
is there, to read results by row such as: <esql:results>  <esql:row-results>
?

Thanks a lot,
Hill

Cocoon 2.1; Tomcat 4.0; JDK SDK 1.3.1; OS WinNT 4.0;

---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>


Re: DatabaseSelectAction, get results

Posted by Christian Haul <ha...@dvs1.informatik.tu-darmstadt.de>.
On 15.May.2002 -- 09:05 PM, Hiloliddin Karimov wrote:
> Hi,
> 
> I try use DatabaseSelectAction for selection. I have searched in the
> archive, but I haven't found solution, please help.
> If I want select all, I try:
> <table name="users">
>   <values>
>     <value param="username" dbcol="username" type="string"/>
>     <value param="balance" dbcol="balance" type="double"/>
>     <value param="status" dbcol="status" type="string"/>
>   </values>
> </table>
> then SQL is: SELECT username, balance, status FROM users WHERE
> and error: unexpected end of SQL command.
> why DatabaseSelectAction still use WHERE?

The DatabaseSelectAction is not meant to be a general database
access. You cannot specify arbitrary where clause for example. Just
retrieve a single row from a table. Of course it could be changed to
not use "WHERE" if no keys are present. But how often do you really
want to retrieve _all_ rows from a database table?

> 2. How can I get results? 
> I see in the "Request logicsheet elements" I can get some more results by
> use:
> <xsp-request:get-parameter-values name="username"/> isn't it?
> is there, to read results by row such as: <esql:results>  <esql:row-results>

Results are stored in request attributes (_not_ parameters!). In
addition, results have a prefix
"org.apache.cocoon.acting.AbstractDatabaseAction:"

Maybe it would be worthwhile to look into the esql logicsheet.

	Chris.

-- 
C h r i s t i a n       H a u l
haul@informatik.tu-darmstadt.de
    fingerprint: 99B0 1D9D 7919 644A 4837  7D73 FEF9 6856 335A 9E08

---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>