Using escape strings in an insert statement.

From: Paul Lambert <paul(dot)lambert(at)autoledgers(dot)com(dot)au>
To: pgsql-sql(at)postgresql(dot)org
Subject: Using escape strings in an insert statement.
Date: 2007-07-02 22:45:20
Message-ID: 46898000.7030601@autoledgers.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Michael Glaesemann 2007-07-02 23:11:09 Re: Using escape strings in an insert statement.
Previous Message Loredana Curugiu 2007-07-02 16:49:54 Re: Replace usage of a table in query with its array values