| From: | Richard Huxton <dev(at)archonet(dot)com> | 
|---|---|
| To: | "Vaughn Cleminson" <vaughn(at)the-i-junction(dot)com(dot)removethis>, pgsql-sql(at)postgresql(dot)org | 
| Subject: | Re: Does Postgres replace \\ with \ in an update query | 
| Date: | 2002-11-15 18:48:35 | 
| Message-ID: | 200211151848.35639.dev@archonet.com | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | 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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Peter T. Brown | 2002-11-15 20:33:29 | how can I improve the speed of this query | 
| Previous Message | Josh Berkus | 2002-11-15 18:07:56 | Re: Updating a table column with ref integrity |