Re: Does Postgres replace \\ with \ in an update query

Поиск
Список
Период
Сортировка
От Richard Huxton
Тема Re: Does Postgres replace \\ with \ in an update query
Дата
Msg-id 200211151848.35639.dev@archonet.com
обсуждение исходный текст
Ответ на Does Postgres replace \\ with \ in an update query  ("Vaughn Cleminson" <vaughn@the-i-junction.com.removethis>)
Список pgsql-sql
On Friday 15 Nov 2002 7:23 am, Vaughn Cleminson wrote:
> Hi All
>
> I am doing a normal SQL update against postgres.
> Seems to be replacing \\ with \ when it gets saved in the database. eg.
> \\machine\folder is being replaced with \machine
>
> Any ideas?

The backslash (\) character is used to escape other characters from normal
interpretation, so you can have a text value: 'Richard\'s text' which means
during processing the backslash is removed.

If you want to actually have a backslash in your sql you'll need to escape it
too. So you'll have something like:

INSERT INTO foo (path) VALUES ('\\\\machine\\folder');

Most application languages offer something like a quote_sql() function which
handles all the details of this for you.

--  Richard Huxton


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

Предыдущее
От: "Josh Berkus"
Дата:
Сообщение: Re: Updating a table column with ref integrity
Следующее
От: "Peter T. Brown"
Дата:
Сообщение: how can I improve the speed of this query