Re: Strange Result with char concatenation in query.

From: Manfred Koizar <mkoi-pg(at)aon(dot)at>
To: "mathieu(dot)chappuis(at)msg-software(dot)com" <mathieu(dot)chappuis(at)msg-software(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Strange Result with char concatenation in query.
Date: 2002-05-27 21:47:46
Message-ID: 2r95fu4tqeho7jnkmdljimo61jtj6v50lv@4ax.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, 24 May 2002 16:09:54 +0200,
"mathieu(dot)chappuis(at)msg-software(dot)com"
<mathieu(dot)chappuis(at)msg-software(dot)com> wrote:
>Hello,
>
>A short example, is IMHO more explicit :
>
>% cat file.csv
>1,100/100
>2,100/100
>3,200/200

I bet, your input lines end with <CR>/<LF> (carriage return/linefeed).
On COPY FROM the <CR> is stored as the last character of chartst.

>test_db=> SELECT '+'||numtst||'+' AS "numtst", '*'||chartst||'-' AS "chartst" FROM test;
> numtst | chartst
>--------+------------
>-+2+ | *100/100

Your terminal gets
+2+ | *100/100<CR>-

<CR> sends the cursor to the start of the line, so you see the - in
front of the rest. Just to illustrate this, try

SELECT '+'||numtst||'+' AS "numtst", '*'||chartst||'-abc-' AS
"chartst" FROM test;

and you will get
numtst | chartst
--------+------------
-abc- | *100/100

Servus
Manfred

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Larry Rosenman 2002-05-27 22:15:28 Re: Altering existing table to be WITHOUT OIDs
Previous Message Tom Lane 2002-05-27 21:21:00 Re: Strange Result with char concatenation in query.