You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Chris Newland <ch...@emorphia.com> on 2001/08/20 13:21:15 UTC
Possible to assign SQL query result to XSP variable?
Hi All,
I'm trying to test for the presence of a key in an SQL table by performing
an SQL query and having the result (or null) set in an XSP variable:
<para>checking for username = <xsp:expr>username</xsp:expr></para>
String got_uname = "dummy";
<esql:connection>
<esql:pool>my_jdbc</esql:pool>
<esql:execute-query>
<esql:query>
select id from enduser where enduser.id =
<esql:parameter><xsp:expr>username</xsp:expr></esql:parameter>
</esql:query>
<esql:row-results>
got_uname = <esql:get-string column="id"/>;
</esql:row-results>
</esql:execute-query>
</esql:connection>
<para>got value from db uname = <xsp:expr>got_uname</xsp:expr></para>
where 'id' is the primary key column in the enduser table.
Is this even a rational thing to try and do?
When the page executes, the value for got_uname is "dummy" and the Java code
created from the page does not attempt to assign the got_uname variable to
the SQL result.
Can somebody let me know if it is actually possible/reasonable to try and
assign XSP variables from SQL queries?
Thanks for your help,
Chris
---------------------------------------------------------------------
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: Possible to assign SQL query result to XSP variable?
Posted by Chris Newland <ch...@emorphia.com>.
Thanks Max,
It was that and the fact that I'd forgotton the <esql:results> around the
<esql:row-results>.
This code works for retrieving a value or null if it does not exist in the
DB:
<para>checking for username = <xsp:expr>username</xsp:expr></para>
String got_uname = "dummy";
<esql:connection>
<esql:pool>lh_jdbc</esql:pool>
<esql:execute-query>
<esql:query>
select id from enduser where enduser.id =
<esql:parameter><xsp:expr>username</xsp:expr></esql:parameter>
</esql:query>
<esql:results>
<esql:row-results>
FOUND RESULTS
<xsp:logic>
got_uname = <esql:get-string column="id"/>;
</xsp:logic>
</esql:row-results>
</esql:results>
<esql:no-results>
NO RESULTS
<xsp:logic>
got_uname = null;
</xsp:logic>
</esql:no-results>
</esql:execute-query>
</esql:connection>
<para>got value from db uname = <xsp:expr>got_uname</xsp:expr></para>
Best Regards,
Chris
> -----Original Message-----
> From: Max Larsson [mailto:max.larsson@gmservice.de]
> Sent: 20 August 2001 12:24
> To: cocoon-users@xml.apache.org
> Subject: AW: Possible to assign SQL query result to XSP variable?
>
>
> Hi,
>
> try to wrap it in a xsp:logic block:
>
> ...
> <esql:execute-query>
> <esql:row-results>
> <xsp:logic>
> got_uname = <esql:get-string column="id"/>;
> </xsp:logic>
> </esql:row-results>
> </esql:execute-query>
> ...
>
> Max
>
> > -----Ursprngliche Nachricht-----
> > Von: Chris Newland [mailto:chris.newland@emorphia.com]
> > Gesendet: Montag, 20. August 2001 13:21
> > An: Cocoon-Users
> > Betreff: Possible to assign SQL query result to XSP variable?
> >
> >
> > Hi All,
> >
> > I'm trying to test for the presence of a key in an SQL table
> > by performing
> > an SQL query and having the result (or null) set in an XSP variable:
> >
> > <para>checking for username = <xsp:expr>username</xsp:expr></para>
> >
> > String got_uname = "dummy";
> >
> > <esql:connection>
> > <esql:pool>my_jdbc</esql:pool>
> > <esql:execute-query>
> > <esql:query>
> > select id from enduser where enduser.id =
> > <esql:parameter><xsp:expr>username</xsp:expr></esql:parameter>
> > </esql:query>
> > <esql:row-results>
> > got_uname = <esql:get-string column="id"/>;
> > </esql:row-results>
> > </esql:execute-query>
> > </esql:connection>
> >
> > <para>got value from db uname = <xsp:expr>got_uname</xsp:expr></para>
> >
> > where 'id' is the primary key column in the enduser table.
> >
> > Is this even a rational thing to try and do?
> >
> > When the page executes, the value for got_uname is "dummy"
> > and the Java code
> > created from the page does not attempt to assign the
> > got_uname variable to
> > the SQL result.
> >
> > Can somebody let me know if it is actually
> > possible/reasonable to try and
> > assign XSP variables from SQL queries?
> >
> > Thanks for your help,
> >
> > Chris
> >
> >
> >
> > ---------------------------------------------------------------------
> > 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>
> >
> >
>
>
> ---------------------------------------------------------------------
> 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>
>
>
>
---------------------------------------------------------------------
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>
AW: Possible to assign SQL query result to XSP variable?
Posted by Max Larsson <ma...@gmservice.de>.
Hi,
try to wrap it in a xsp:logic block:
...
<esql:execute-query>
<esql:row-results>
<xsp:logic>
got_uname = <esql:get-string column="id"/>;
</xsp:logic>
</esql:row-results>
</esql:execute-query>
...
Max
> -----Ursprüngliche Nachricht-----
> Von: Chris Newland [mailto:chris.newland@emorphia.com]
> Gesendet: Montag, 20. August 2001 13:21
> An: Cocoon-Users
> Betreff: Possible to assign SQL query result to XSP variable?
>
>
> Hi All,
>
> I'm trying to test for the presence of a key in an SQL table
> by performing
> an SQL query and having the result (or null) set in an XSP variable:
>
> <para>checking for username = <xsp:expr>username</xsp:expr></para>
>
> String got_uname = "dummy";
>
> <esql:connection>
> <esql:pool>my_jdbc</esql:pool>
> <esql:execute-query>
> <esql:query>
> select id from enduser where enduser.id =
> <esql:parameter><xsp:expr>username</xsp:expr></esql:parameter>
> </esql:query>
> <esql:row-results>
> got_uname = <esql:get-string column="id"/>;
> </esql:row-results>
> </esql:execute-query>
> </esql:connection>
>
> <para>got value from db uname = <xsp:expr>got_uname</xsp:expr></para>
>
> where 'id' is the primary key column in the enduser table.
>
> Is this even a rational thing to try and do?
>
> When the page executes, the value for got_uname is "dummy"
> and the Java code
> created from the page does not attempt to assign the
> got_uname variable to
> the SQL result.
>
> Can somebody let me know if it is actually
> possible/reasonable to try and
> assign XSP variables from SQL queries?
>
> Thanks for your help,
>
> Chris
>
>
>
> ---------------------------------------------------------------------
> 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>
>
>
---------------------------------------------------------------------
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>