You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ted Husted <hu...@apache.org> on 2001/05/31 21:58:12 UTC
OT: LIKE with PrepareStatement
Not directly Struts related, but anyway, I'm trying to use "LIKE '%?%'"
as part of a prepared statement, but it's coming back invalid array
index. Apparently, the symbols are hiding the question mark. Anyone know
a way around this, besides doing the substitution and escape-coding the
old-fashioned way?
-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel 716 737-3463.
-- http://www.husted.com/about/struts/
Re: LIKE with PrepareStatement
Posted by Jeff Trent <jt...@structsoft.com>.
Ted,
I am assuming your query uses bind variable and you already know that
offsets start with 1, and not 0. So besides that, the way I would get
around this is by doing something like this:
searchStr += "%" + searchStr + "%";
String strSql = "select x from y where y.z like ?";
ps.setString(1, searchStr);
----- Original Message -----
From: "Ted Husted" <hu...@apache.org>
To: <st...@jakarta.apache.org>
Sent: Thursday, May 31, 2001 3:58 PM
Subject: OT: LIKE with PrepareStatement
> Not directly Struts related, but anyway, I'm trying to use "LIKE '%?%'"
> as part of a prepared statement, but it's coming back invalid array
> index. Apparently, the symbols are hiding the question mark. Anyone know
> a way around this, besides doing the substitution and escape-coding the
> old-fashioned way?
>
> -- Ted Husted, Husted dot Com, Fairport NY USA.
> -- Custom Software ~ Technical Services.
> -- Tel 716 737-3463.
> -- http://www.husted.com/about/struts/
>
Re: LIKE with PrepareStatement
Posted by Ryan Rich <RR...@bitek.com>.
For Oracle anyways, inside a prepared statement you could use " ... like '%'
|| ? || '%' ..."
Ryan Rich
----------------
Bitek, Inc.
2569 West Woodland Dr.
Anaheim, CA 92801
(714) 828-8388
----- Original Message -----
From: "Ted Husted" <hu...@apache.org>
To: <st...@jakarta.apache.org>
Sent: Thursday, May 31, 2001 12:58 PM
Subject: OT: LIKE with PrepareStatement
> Not directly Struts related, but anyway, I'm trying to use "LIKE '%?%'"
> as part of a prepared statement, but it's coming back invalid array
> index. Apparently, the symbols are hiding the question mark. Anyone know
> a way around this, besides doing the substitution and escape-coding the
> old-fashioned way?
>
> -- Ted Husted, Husted dot Com, Fairport NY USA.
> -- Custom Software ~ Technical Services.
> -- Tel 716 737-3463.
> -- http://www.husted.com/about/struts/