Re: Does Postgres replace \\ with \ in an update query - Mailing list pgsql-sql

From Richard Huxton
Subject Re: Does Postgres replace \\ with \ in an update query
Date
Msg-id 200211151848.35639.dev@archonet.com
Whole thread Raw
In response to Does Postgres replace \\ with \ in an update query  ("Vaughn Cleminson" <vaughn@the-i-junction.com.removethis>)
List 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 by date:

Previous
From: "Josh Berkus"
Date:
Subject: Re: Updating a table column with ref integrity
Next
From: "Peter T. Brown"
Date:
Subject: how can I improve the speed of this query