Using escape strings in an insert statement. - Mailing list pgsql-sql

From Paul Lambert
Subject Using escape strings in an insert statement.
Date
Msg-id 46898000.7030601@autoledgers.com.au
Whole thread Raw
Responses Re: Using escape strings in an insert statement.  (Michael Glaesemann <grzm@seespotcode.net>)
List pgsql-sql
I'm having a little glitch in using escape strings within strings.

The following will best explain my issue:

tester=# create table testing (test_text text);
CREATE TABLE

tester=# insert into testing (test_text) values ('abc\\123');
WARNING:  nonstandard use of \\ in a string literal
LINE 1: insert into testing (test_text) values ('abc\\123');                                                ^
HINT:  Use the escape string syntax for backslashes, e.g., E'\\'.
INSERT 0 1

^^^ This works, but I still get an error/warning telling me to use E'\\'  - which I do:

tester=# insert into testing (test_text) values ('abcE'\\'123');
Invalid command \. Try \? for help.
tester(#

^^^ And this just doesn't work at all.


The help itself (ch 4.1.2.1) tells me to use double backslash "Thus, to 
include a backslash character, write two backslashes (\\). "

Which one is the correct syntax and how can I make it not return 
anything other than a successful insert?

Noob question, I know...

But TIA.

(Version is 8.2.3 on Weenblowz if that is of any relevance)

--
Paul Lambert
Database Administrator
AutoLedgers


pgsql-sql by date:

Previous
From: "Loredana Curugiu"
Date:
Subject: Replace usage of a table in query with its array values
Next
From: Michael Glaesemann
Date:
Subject: Re: Using escape strings in an insert statement.