pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: lars@ellebjerg.net
To: pgsql-bugs@postgresql.org
Subject: BUG #14485: Error in copy from temp
Date: Wed, 04 Jan 2017 14:15:54 +0000
Message-ID: <20170104141554.10141.50575@wrigleys.postgresql.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

The following bug has been logged on the website:

Bug reference:      14485
Logged by:          Lars Ellebjerg
Email address:      lars@ellebjerg.net
PostgreSQL version: 9.6.0
Operating system:   Windows
Description:        

I believe I have experienced an error in copying from a temporary table.

I have a csv-file with a column of ten-digit person registry numbers, some
of which start with zero.
I need to copy them to a column 'cpr' in a table, which also contains an id
serial column.
If I do this by copying them to a temp table with a single text column, and
then inserting them into the permanent table, the initial zero is removed
somewhere between the temp and the permanent table.
If I do the same using a permanent table instead of the temp table, the copy
works fine including the initial zeros.

create temporary table t (x1 text);

copy t (x1)
from 'C:/CPR hjemmesygepleje.csv' delimiter ';' csv;

insert into aeldrepleje.hjemmesygeplejemodtagere (cpr)
select x1 from t;

select * from aeldrepleje.hjemmesygeplejemodtagere;


create table aeldrepleje.hspm (cpr text);

copy aeldrepleje.hspm (cpr)
from 'C:/CPR hjemmesygepleje.csv' delimiter ';' csv;

insert into aeldrepleje.hjemmesygeplejemodtagere (cpr)
select cpr from aeldrepleje.hspm;

select * from aeldrepleje.hjemmesygeplejemodtagere;



-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs


view thread (2+ messages)  latest in thread

Message-ID: <20170104141554.10141.50575@wrigleys.postgresql.org>
Permalink:  ../20170104141554.10141.50575@wrigleys.postgresql.org/
Also on:    postgresql.org/message-id/20170104141554.10141.50575@wrigleys.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: lars@ellebjerg.net
  Subject: Re: BUG #14485: Error in copy from temp
  In-Reply-To: <20170104141554.10141.50575@wrigleys.postgresql.org>
  References: <20170104141554.10141.50575@wrigleys.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox