Search Postgresql Archives

Re: how to insert '\\' in postgres database using java

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

 



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



---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

              http://www.postgresql.org/docs/faq

[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