From: | Michael Glaesemann <grzm(at)myrealbox(dot)com> |
---|---|
To: | ketan shah <ketan_dba(at)yahoo(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: how to insert '\\' in postgres database using java |
Date: | 2005-07-15 14:49:47 |
Message-ID: | 69FF9B85-B642-47CA-B2E7-12314073811A@myrealbox.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi Ketan,
On Jul 15, 2005, at 10:49 PM, ketan shah wrote:
> My question :
> After updation how i get
> 'A', 'Mr. B', 'A\\d\\d\\d\\d'
> i.e. not escapeing '\\'.
> I am using postgres 7.4.6 and java 1.4.
> pl. help me out...
As you've noticed, the \ character is currently used in PostgreSQL as
an escape, so '\\' is recognized as one \. So if you want to insert \
\, you need to escape both \; i.e., '\\\\'
test=# select '\\';
?column?
----------
\
(1 row)
test=# select '\\\\';
?column?
----------
\\
(1 row)
test=# create table tab1 (
usr_id varchar(15)
, usr_name varchar(20)
,usr_filename_pattern varchar(1024)
);
CREATE TABLE
test=# insert into tab1 (usr_id, usr_name, usr_filename_pattern)
values ('A','Mr. A','A\\d\\d\\d\\d');
INSERT 82771 1
test=# insert into tab1 (usr_id, usr_name, usr_filename_pattern)
values ('A','Mr. B','A\\\\d\\\\d\\\\d\\\\d');
INSERT 82772 1
test=# select * from tab1;
usr_id | usr_name | usr_filename_pattern
--------+----------+----------------------
A | Mr. A | A\d\d\d\d
A | Mr. B | A\\d\\d\\d\\d
(2 rows)
Is this what you're looking for?
As an aside, I find it very helpful to name the columns when I'm
inserting them. (INSERT INTO foo (bar, baz, bat) VALUES ... instead
of INSERT INTO foo VALUES ... )Then I don't have to remember exactly
which column order I used when creating the table.
Hope this helps.
Michael Glaesemann
grzm myrealbox com
From | Date | Subject | |
---|---|---|---|
Next Message | Scott cox | 2005-07-15 15:08:24 | (Win32 Postgres) Slow to Connect first - OK afterwards |
Previous Message | Dinesh Pandey | 2005-07-15 14:38:50 | Postgres for Fedora Core 2 OS **************** |