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

Поиск
Список
Период
Сортировка
От Michael Glaesemann
Тема Re: how to insert '\\' in postgres database using java
Дата
Msg-id 69FF9B85-B642-47CA-B2E7-12314073811A@myrealbox.com
обсуждение исходный текст
Ответ на how to insert '\\' in postgres database using java  (ketan shah <ketan_dba@yahoo.com>)
Список 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



В списке pgsql-general по дате отправления:

Предыдущее
От: "Dinesh Pandey"
Дата:
Сообщение: Postgres for Fedora Core 2 OS ****************
Следующее
От: "Greg Patnude"
Дата:
Сообщение: Re: How to obtain the list of data table name only