Re: Especial delimiters caracter

From: Oliver Elphick <olly(at)lfix(dot)co(dot)uk>
To: "Montervino, Mariano" <montervi(at)cabal(dot)com(dot)ar>
Cc: "'pgsql-general(at)postgresql(dot)org'" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Especial delimiters caracter
Date: 2003-09-24 05:53:05
Message-ID: 1064382784.6612.27.camel@linda.lfix.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, 2003-09-23 at 15:47, Montervino, Mariano wrote:
> running the following script
>
> select ('cabal\\' || user_name) into temporary user_access from
> tbl_user_access where access_profile_id = 4;
> copy user_access to '/temp/users.txt' delimiters '|';
>
> The result of the output file is...
> domain\\users
> but the field in the temp table is...
> domain\users

That is because COPY produces output that is suitable for input, and on
input backslashes must be escaped. There is no way to change this
behaviour.

> I need the same result like temp table. How could i do it??

Assuming a Unix system, process the file with sed:

sed -e 's|\\\\|\\|g' /temp/users.txt > $$; mv $$ /temp/users.txt

(Note that the backslashes have to be escaped for sed, too.)

--
Oliver Elphick Oliver(dot)Elphick(at)lfix(dot)co(dot)uk
Isle of Wight, UK http://www.lfix.co.uk/oliver
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C
========================================
"And we know that all things work together for good to
them that love God, to them who are the called
according to his purpose."
Romans 8:28

In response to

Browse pgsql-general by date

  From Date Subject
Next Message shreedhar 2003-09-24 06:05:22 Re: Fatal error: Allowed memory size of 8388608 bytes exhausted
Previous Message Oliver Elphick 2003-09-24 05:35:34 Re: GET LAST ID INSERT