Re: Carraige Return issues

From: Oliver Elphick <olly(at)lfix(dot)co(dot)uk>
To: caroline kenny <caroline_kenny(at)hotmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Carraige Return issues
Date: 2002-07-05 12:27:00
Message-ID: 1025872021.31584.21.camel@linda
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, 2002-07-05 at 11:51, caroline kenny wrote:
> Thanks Oliver for your help....but I'm still having a small issue..
>
> What Im really trying to do is to insert/update a field in a particular
> table through perl script.
> When i run the perl script to insert the specifics into my table...i want
> that the file that to be entered into the specific field will be put in with
> its carriage returns....can u help further

So you're using UPDATE or INSERT called through your Perl script?

You need to replace newline with \n in the data being inserted or escape
the linefeeds with \. You also need to escape any real backslash with
an extra backslash and you need to escape single-quotes, either with a
backslash or an extra single-quote.

junk=# insert into tt values (3,'Line 1 of ''some\ntext with\
junk'# linefeeds in it\n and \\s too.');
INSERT 27417478 1
junk=# select t from tt where id = 3;
t
--------------------------------------------------------
Line 1 of 'some
text with
linefeeds in it
and \s too.
(1 row)

If you're using Windows, you may also have to deal with their use of
CRLF as a line ending, as opposed to Unix's LF, but all that can be done
in Perl.

The Perl coding is left as an exercise for the reader - meaning I can't
work it out without looking things up!

Oliver

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Alessio Bragadini 2002-07-05 12:37:51 Re: Should next release by 8.0 (Was: Re: [GENERAL] I am
Previous Message CoL 2002-07-05 12:13:23 Re: Comparing PostgreSQL and Oracle stability