How to use SQL functions with parameters?
"Francesco Martinelli" <[email protected]>
| Newsgroups | gmane.comp.jakarta.ojb.user |
|---|---|
| Message-ID | <[email protected]> |
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.