Обсуждение: Especial delimiters caracter

Поиск
Список
Период
Сортировка

Especial delimiters caracter

От
"Montervino, Mariano"
Дата:
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

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

RGDS


Re: Especial delimiters caracter

От
Oliver Elphick
Дата:
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