You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by crmanoj <ma...@gmail.com> on 2009/12/11 09:42:32 UTC

Search for character '_', '%' wildcard characters using ibatis

I am developing a webapplication using Struts for which oracle is a backend.
For connectivity i am using iBatis. My application has a search page where
the user enters an id which inturn gets the data from DB. 
The primary key for table which i am using is of type 'VARCHAR'. The values
for this primarykey field can contain characters like '_', '%' which are
wildcard characters.
 
For example:
id                 name
user_1          Tom
user_2          Harry
 
Suppose if a user wants to search for all rows which has '_' in their
primary key, how do i get this in iBatis. In a normal sql query in oracle, i
can use the keyword 'ESCAPE' for escaping the special characters.
For eg: 
SELECT id,name FROM EMPLOYEE WHERE id LIKE '%\_%' ESCAPE '\'
 
How do i handle this in iBatis?.
 
I am using the method 'queryforlist' in java to get the data. 
In SqlMap, i am using <select> tag.
 
Thanks in Advance.
-- 
View this message in context: http://old.nabble.com/Search-for-character-%27_%27%2C-%27-%27-wildcard-characters-using-ibatis-tp26740551p26740551.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org


Re: Search for character '_', '%' wildcard characters using ibatis

Posted by crmanoj <ma...@gmail.com>.
Hi, Thanks for the reply. 
I tried the same way with ibatis. I'm getting error(SQL Exception). 

Here is the error, 

 java.sql.SQLException: ORA-00933: SQL command not properly ended

	at
oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
	at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
	at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
	at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743)
	at
oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:216)
	at
oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:799)
	at
oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1038)
	at
oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:839)
	at
oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1133)
	at
oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3285)
	at
oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3390)
	at
com.ibatis.sqlmap.engine.execution.SqlExecutor.executeQuery(SqlExecutor.java:185)
	at
com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.sqlExecuteQuery(MappedStatement.java:221)
	at
com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeQueryWithCallback(MappedStatement.java:189)
	... 7 more

Please help me with this..

Manoj

------------------------------

Larry Meadors wrote:
> 
> You should be able to do it the same way with ibatis...did you try it?
> Did you get an error? Can you pass the error along?
> 
> Larry
> 
> 
> On Fri, Dec 11, 2009 at 1:42 AM, crmanoj <ma...@gmail.com> wrote:
>>
>> I am developing a webapplication using Struts for which oracle is a
>> backend.
>> For connectivity i am using iBatis. My application has a search page
>> where
>> the user enters an id which inturn gets the data from DB.
>> The primary key for table which i am using is of type 'VARCHAR'. The
>> values
>> for this primarykey field can contain characters like '_', '%' which are
>> wildcard characters.
>>
>> For example:
>> id                 name
>> user_1          Tom
>> user_2          Harry
>>
>> Suppose if a user wants to search for all rows which has '_' in their
>> primary key, how do i get this in iBatis. In a normal sql query in
>> oracle, i
>> can use the keyword 'ESCAPE' for escaping the special characters.
>> For eg:
>> SELECT id,name FROM EMPLOYEE WHERE id LIKE '%\_%' ESCAPE '\'
>>
>> How do i handle this in iBatis?.
>>
>> I am using the method 'queryforlist' in java to get the data.
>> In SqlMap, i am using <select> tag.
>>
>> Thanks in Advance.
>> --
>> View this message in context:
>> http://old.nabble.com/Search-for-character-%27_%27%2C-%27-%27-wildcard-characters-using-ibatis-tp26740551p26740551.html
>> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
>> For additional commands, e-mail: user-java-help@ibatis.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-java-help@ibatis.apache.org
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/Search-for-character-%27_%27%2C-%27-%27-wildcard-characters-using-ibatis-tp26740551p26886176.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org


Re: Search for character '_', '%' wildcard characters using ibatis

Posted by Larry Meadors <la...@gmail.com>.
You should be able to do it the same way with ibatis...did you try it?
Did you get an error? Can you pass the error along?

Larry


On Fri, Dec 11, 2009 at 1:42 AM, crmanoj <ma...@gmail.com> wrote:
>
> I am developing a webapplication using Struts for which oracle is a backend.
> For connectivity i am using iBatis. My application has a search page where
> the user enters an id which inturn gets the data from DB.
> The primary key for table which i am using is of type 'VARCHAR'. The values
> for this primarykey field can contain characters like '_', '%' which are
> wildcard characters.
>
> For example:
> id                 name
> user_1          Tom
> user_2          Harry
>
> Suppose if a user wants to search for all rows which has '_' in their
> primary key, how do i get this in iBatis. In a normal sql query in oracle, i
> can use the keyword 'ESCAPE' for escaping the special characters.
> For eg:
> SELECT id,name FROM EMPLOYEE WHERE id LIKE '%\_%' ESCAPE '\'
>
> How do i handle this in iBatis?.
>
> I am using the method 'queryforlist' in java to get the data.
> In SqlMap, i am using <select> tag.
>
> Thanks in Advance.
> --
> View this message in context: http://old.nabble.com/Search-for-character-%27_%27%2C-%27-%27-wildcard-characters-using-ibatis-tp26740551p26740551.html
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-java-help@ibatis.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org