ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeff Butler" <jeffgbut...@gmail.com>
Subject Re: parameter map and like %?% query
Date Thu, 15 Feb 2007 22:28:06 GMT
You could also do this:

select *
from some_table
where firstName like '%$firstName$%'

Jeff Butler



On 2/15/07, cmose <cjmose@gmail.com> wrote:
>
>
> Milo,
> thanks for that information - I had hoped to not have to put the wildcards
> in the parameter programmatically prior to calling the statement via
> sqlmapclient...
>
> I'm not familiar with getting an instance of the parametermap
> programmatically - could you give me a brief pointer to where in the
> documentaiton I might find that functionality? Thanks  much.
>
>
>
> Todorovich, Milo wrote:
> >
> > Instead of coding the % signs into your statements, make them a part of
> > the parameter that is passed in. Here's an example:
> >
> > <select id="selectLikeName">
> >     select * from person where first_name like #nameParm#
> > </select>
> >
> >
> > Then your code can call this statement like this:
> >
> > parameterMap.put("nameParm", "%"+nameParmValue+"%");
> > List results = sqlMapClient.queryForList("selectLikeName",
> > parameterMap);
> >
> >
> > Good luck!
> > -Milo
> >
> >
> > -----Original Message-----
> > From: cmose [mailto:cjmose@gmail.com]
> > Sent: Thursday, February 15, 2007 4:06 PM
> > To: user-java@ibatis.apache.org
> > Subject: parameter map and like %?% query
> >
> >
> > I hope this isn't a blatantly obvious question but it may well be...
> >
> > I'm trying to do a LIKE query using either a parameter map or an inline
> > parameter map and I can't seem to get that to work with the % and %
> > characters, what I would like to do is something along the lines of LIKE
> > %?% or LIKE %#value#%  however, I can't seem to get that working. Every
> > time I try it using %?% I get a mysql syntax error indicating that
> > ibatis is adding quotes around the %'s e.g,. '%'value'%' which causes
> > mysql to barf.
> >
> > I tried quoting the %?%, e.g., "%?%" but that causes ibatis to barf
> > saying that it can't find a parameter...
> >
> > Does anyone have advice/can point out something obvious that I'm missing
> > or is this just not possible?
> >
> > Thanks!
> > --
> > View this message in context:
> > http://www.nabble.com/parameter-map-and-like-----query-tf3236388.html#a8
> > 994700
> > Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
> >
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/RE%3A-parameter-map-and-like-----query-tf3236438.html#a8994979
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>
>

Mime
View raw message