Search Postgresql Archives

Re: Escaping special characters

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



	Neanderthelle Jones wrote:

About the string "Smith \& Jones".

According to the documentation,

INSERT INTO thing (name) VALUES ('Smith E'\\'& Jones');

must work.  But it doesn't.  So, double the enclosed quotes:

INSERT INTO thing (name) VALUES ('Smith E''\\''& Jones');

The E can't be inside the string, it must appear before the quote starting the string.

But first, you need to choose a setting for standard_conforming_strings, especially if you're concerned with compatibility against future versions. Either your session has standard_conforming_strings set to ON or set to OFF. This is what defines which characters have to be quoted and how.

if OFF you must escape the backslash:
test=> set standard_conforming_strings=off;
SET
test=> select E'Smith \\& Jones';
   ?column?	
----------------
Smith \& Jones
(1 row)

if ON you don't:
test=> set standard_conforming_strings=on;
SET
test=> select 'Smith \& Jones';
   ?column?	
----------------
Smith \& Jones
(1 row)

ON is supposed to become the default at some point in the future.

Cordialement,
--
Daniel

--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux