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 Mark Nabours <ma...@yahoo.com> on 2004/12/28 04:39:17 UTC
SQL Help -- Escape $ in case expression
Hello!
I have a case expression in my SQL query similar to
the following:
sum(case when code = 'tck$' then amount else 0 end) as
ticketSales
When the case expression is written like that, I
receive a
com.ibatis.common.jdbc.exception.NestedSQLException.
I changed the case expression to the following and it
works just fine:
sum(case when code like 'tck%' then amount else 0 end)
as ticketSales
Is there a way to escape the $ in my SQL query so that
it won't cause a
com.ibatis.common.jdbc.exception.NestedSQLException?
Or in general how do you escape characters in your SQL
query that have special meaning in iBatis (like the
#)?
Thanks,
Mark
__________________________________
Do you Yahoo!?
Yahoo! Mail - Easier than ever with enhanced search. Learn more.
http://info.mail.yahoo.com/mail_250
Re: SQL Help -- Escape $ in case expression
Posted by Clinton Begin <cl...@gmail.com>.
Yep. Both # and $ can be escaped by doubling: ## or $$ respectively.
Clinton
On Mon, 27 Dec 2004 19:39:17 -0800 (PST), Mark Nabours
<ma...@yahoo.com> wrote:
> Hello!
>
> I have a case expression in my SQL query similar to
> the following:
>
> sum(case when code = 'tck$' then amount else 0 end) as
> ticketSales
>
> When the case expression is written like that, I
> receive a
> com.ibatis.common.jdbc.exception.NestedSQLException.
>
> I changed the case expression to the following and it
> works just fine:
>
> sum(case when code like 'tck%' then amount else 0 end)
> as ticketSales
>
> Is there a way to escape the $ in my SQL query so that
> it won't cause a
> com.ibatis.common.jdbc.exception.NestedSQLException?
>
> Or in general how do you escape characters in your SQL
> query that have special meaning in iBatis (like the
> #)?
>
> Thanks,
> Mark
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Mail - Easier than ever with enhanced search. Learn more.
> http://info.mail.yahoo.com/mail_250
>