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