You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@phoenix.apache.org by Vijay Vangapandu <Vi...@eharmony.com> on 2015/11/09 23:40:51 UTC

Issue with single quote in columns with String data type

Hi Guys,

Does any one encounter a situation where single quote needs to be inserted into
String data type column. ex: I am trying insert “xxx’y” in to the city column of my address table, but causing issue at insert time due to query contains quote.

I can escape the quote before executing the query, but is there any better or suggested way of handling this case?

ex: upsert into user_address (uid, city, state, country) values(123, ‘L’Anse’, ‘MI’, ‘USA’)


Thanks,
Vijay.


Re: Issue with single quote in columns with String data type

Posted by James Taylor <ja...@apache.org>.
Either escape the quote by using two of them in a row like this:
    upsert into user_address (uid, city, state, country) values(123,
‘L'’Anse’, ‘MI’, ‘USA’)
or use bind parameters like this:
    upsert into user_address (uid, city, state, country) values(?, ?, ?, ?)

Thanks,
James


On Mon, Nov 9, 2015 at 2:40 PM, Vijay Vangapandu <
VijayVangapandu@eharmony.com> wrote:

> Hi Guys,
>
> Does any one encounter a situation where single quote needs to be inserted
> into
> String data type column. ex: I am trying insert “xxx’y” in to the city
> column of my address table, but causing issue at insert time due to query
> contains quote.
>
> I can escape the quote before executing the query, but is there any better
> or suggested way of handling this case?
>
> ex: upsert into user_address (uid, city, state, country) values(123,
> ‘L’Anse’, ‘MI’, ‘USA’)
>
>
> Thanks,
> Vijay.
>
>