ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Larry Meadors" <Larry.Mead...@plumcreek.com>
Subject Re: Using Select...like in XML!
Date Sun, 02 Jan 2005 04:25:37 GMT
You do it the same way you would with a prepared statement with JDBC
directly. Since iBATIS uses PreparedStatement under the covers, you end
up with this:

select * from foo where blah like ?

The only way to make that work is to:

A) change the parameter to be "x%"

or 

B) change the statement to:

select * from foo where blah like 'x%'

You could use the $value$ syntax if you wanted to, but beware of the
usual caveats re: SQL injection.

Larry

>>> brandon.goodin@gmail.com 01/01/05 12:34 PM >>>
try something of the likes of:

Select * from users_table where user_first_name like #M# + '%'

This will vary depending on which database you use. But the only
variance is the concatenation syntax,

Brandon
 

On Wed, 29 Dec 2004 10:04:26 -0500, Ramon Misho <Ramon.Misho@teranet.ca>
wrote:
>  
>  
> 
> Hello IBATIS Support 
> 
> In my XML file, I need to use a combination of  #value#,  like  and
'%'.    
> For example, if I want all information about users whose first names
start
> with a specific letter 
> 
> (say M),  I could write the following statement: 
> 
> Select * from users_table where user_first_name like 'M%' 
> 
>   
> 
> However,  if the letter is stored in #value# then I might consider
writing
> the following statement (which is NOT working) 
> 
>             Select * from users_table where user_first_name like
'#value#%' 
> 
>   
> 
> My question is:  How does IBATIS handle this situation and how do I
make
> such Select statement work? 
> 
>   
> 
>   
> 
> Thanks a lot. 
> 
>   
> 
>   
> 
>   
> 
> Ramon Misho 
> 
> System Analyst / Programmer 
> 
> Mapping Development 
> 
>   
> 
> Teranet Inc. 
> 
> 655 Bay Street, Suite 600 
> 
> Toronto, ON M5G 2K4 
> 
>   
> 
> Phone 416.326.1322 ext 4150 
> 
> Fax 416.314.6140 
> 
> e-mail: ramon.misho@teranet.ca 
> 
> Website: http://www.teranet.ca/ 
> 
>   
> 
> The information in this e-mail is confidential and may be legally
> privileged.  It is intended solely for the addressee.  Access to this
e-mail
> by anyone else is unauthorized.  If you are not the intended
recipient, any
> disclosure, copying, distribution or any action taken or omitted to be
taken
> in reliance on it, is prohibited and may be unlawful. 
> 
>


Mime
View raw message