Sql like operator

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Sql like operator

adev

Hi Guys,

I am trying to use the like operator in my xpl.
The Statement goes in this fashion

<sql:query> 
                 select * from location where location_name like  %<sql:param type="xs:string" select="//@countryname"/>%
</sql:query>

I am expecting the query to be executed as        
 select * from location where location_name like  '%France%' 

but it is getting executed as  select * from location where location_name like  '%'France'%', thus giving error.

how do overcome this? any idea?  
Thanks in advance!!!!

Reply | Threaded
Open this post in threaded view
|

Re: Sql like operator

fl.schmitt(ops-users)
Hi adev,

> <sql:query>
>                  select * from location where location_name like
> %<sql:param type="xs:string" select="//@countryname"/>%
> </sql:query>

> I am expecting the query to be executed as        
>  select * from location where location_name like  '%France%'  
>
> but it is getting executed as  select * from location where location_name
> like  '%'France'%', thus giving error.

Maybe you could add the % signs using the XPath concat() function:

<sql:query>    select * from location where location_name like
     <sql:param
         type="xs:string"
         select="concat('%', //@countryname, '%')"
     />
</sql:query>

But i'm not sure wether this will work.

HTH
florian



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Re: Sql like operator

Erik Bruchez
Administrator
>> <sql:query>

>>                 select * from location where location_name like  
>> %<sql:param type="xs:string" select="//@countryname"/>%
>> </sql:query>
>
>> I am expecting the query to be executed as         select * from  
>> location where location_name like  '%France%'  but it is getting  
>> executed as  select * from location where location_name
>> like  '%'France'%', thus giving error.
>
> Maybe you could add the % signs using the XPath concat() function:
>
> <sql:query>    select * from location where location_name  
> like
>    <sql:param
>        type="xs:string"
>        select="concat('%', //@countryname, '%')"
>    />
> </sql:query>
>
> But i'm not sure wether this will work.
I think it should. The original version most likely won't, because  
sql:param does not just concatenate the parameter in the SQL query: it  
sets a JSBC prepared statement parameter.

-Erik

--
Orbeon Forms - Web Forms for the Enterprise Done the Right Way
http://www.orbeon.com/



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws