pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Richard Huxton <dev@archonet.com>
To: Vaughn Cleminson <vaughn@the-i-junction.com.removethis>
To: pgsql-sql@postgresql.org
Subject: Re: Does Postgres replace \\ with \ in an update query
Date: Fri, 15 Nov 2002 18:48:35 +0000
Message-ID: <200211151848.35639.dev@archonet.com> (raw)
In-Reply-To: <3dd4a0e4.0@news1.mweb.co.za>
References: <3dd4a0e4.0@news1.mweb.co.za>

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



view thread (2+ messages)

Message-ID: <200211151848.35639.dev@archonet.com>
Permalink:  ../200211151848.35639.dev@archonet.com/
Also on:    postgresql.org/message-id/200211151848.35639.dev@archonet.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: dev@archonet.com, vaughn@the-i-junction.com.removethis
  Subject: Re: Does Postgres replace \\ with \ in an update query
  In-Reply-To: <200211151848.35639.dev@archonet.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox