Re: Especial delimiters caracter - Mailing list pgsql-general

From Oliver Elphick
Subject Re: Especial delimiters caracter
Date
Msg-id 1064382784.6612.27.camel@linda.lfix.co.uk
Whole thread Raw
In response to Especial delimiters caracter  ("Montervino, Mariano" <montervi@cabal.com.ar>)
List 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.Elphick@lfix.co.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


pgsql-general by date:

Previous
From: Oliver Elphick
Date:
Subject: Re: GET LAST ID INSERT
Next
From: "shreedhar"
Date:
Subject: Re: [ADMIN] Fatal error: Allowed memory size of 8388608 bytes exhausted