2

i am using Postgresql Db. i got this error for using ' on a text,

unterminated quoted string at or near "'\'')"

it is my function call:

SELECT "public"."sendMessage"(12152015, 12584, 1258487, 13960614093221020, '\'')

how can i insert these characters into db without any problem??

1

1 Answer 1

3

The right way to quote a single quote is to repeat it, not to escape it:

SELECT "public"."sendMessage"(12152015, 12584, 1258487, 13960614093221020, '''')
                                                                            ^^
Sign up to request clarification or add additional context in comments.

5 Comments

and what about double quotation and other special characters user can enter??
@Saeed.At Double quotes are not special characters in a string literal.
Single quote is the only character that you have to escape. It's better to use parameterized queries and have the database library do this for you.
@Saeed.At: see the manual for details: postgresql.org/docs/current/static/…
Also, a single quote can be included in an escape string by writing \', in addition to the normal way of ''.@a_horse_with_no_name , but it does not true, is it?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.