You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Francesco Martinelli <ma...@pi.ingv.it> on 2007/01/31 16:37:24 UTC
How to use SQL functions with parameters?
Dear all,
I need to filter a query using an SQL function.
In SQL this would be achieved with the following statement:
select * from myTable where key in (select * from myFunc(myParam))
I tried the same with ODB-ODBC, and this worked using the following query
string:
String oqlQuery = "select myObject from " + myClass.getName() +
" where key IN (select * from myFunc(" + myParam.toString() + "))";
However it generated an error at the moment of binding the parameter using
the following query string:
String oqlQuery = "select myObject from " + myClass.getName() +
" where key IN (select * from myFunc($1))";
After creating the qury with:
query.create(oqlQuery);
The error (QueryParameterCountInvalidException) was generated at the
following line:
query.bind((Float)myParam);
Can anybody tell me if it is possible to use the query string in the
second form?
Thank you,
Francesco.
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: How to use SQL functions with parameters?
Posted by Armin Waibel <ar...@apache.org>.
Hi Francesco,
the oql-support isn't fully implemented.
http://db.apache.org/ojb/status.html
Maybe it's possible to do a workaround by using the Criteria-API
http://db.apache.org/ojb/docu/guides/odmg-guide.html#no-oql
http://db.apache.org/ojb/docu/guides/query.html#subqueries
regards,
Armin
Francesco Martinelli wrote:
> Dear all,
> I need to filter a query using an SQL function.
>
> In SQL this would be achieved with the following statement:
> select * from myTable where key in (select * from myFunc(myParam))
>
> I tried the same with ODB-ODBC, and this worked using the following query
> string:
> String oqlQuery = "select myObject from " + myClass.getName() +
> " where key IN (select * from myFunc(" + myParam.toString() + "))";
>
> However it generated an error at the moment of binding the parameter using
> the following query string:
> String oqlQuery = "select myObject from " + myClass.getName() +
> " where key IN (select * from myFunc($1))";
>
> After creating the qury with:
> query.create(oqlQuery);
>
> The error (QueryParameterCountInvalidException) was generated at the
> following line:
> query.bind((Float)myParam);
>
> Can anybody tell me if it is possible to use the query string in the
> second form?
>
> Thank you,
> Francesco.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org