pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #14485: Error in copy from temp
2+ messages / 2 participants
[nested] [flat]

* BUG #14485: Error in copy from temp
@ 2017-01-04 14:15  lars@ellebjerg.net
  0 siblings, 1 reply; 2+ messages in thread

From: lars@ellebjerg.net @ 2017-01-04 14:15 UTC (permalink / raw)
  To: pgsql-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


^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: BUG #14485: Error in copy from temp
@ 2017-01-05 00:00  Michael Paquier <michael.paquier@gmail.com>
  parent: lars@ellebjerg.net
  0 siblings, 0 replies; 2+ messages in thread

From: Michael Paquier @ 2017-01-05 00:00 UTC (permalink / raw)
  To: lars@ellebjerg.net; +Cc: pgsql-bugs

On Wed, Jan 4, 2017 at 11:15 PM,  <lars@ellebjerg.net> wrote:
> 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;

Could you send a minimal data CSV set to reproduce your problem? That
would be helpful to look at what you reported here.
-- 
Michael


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



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2017-01-05 00:00 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2017-01-04 14:15 BUG #14485: Error in copy from temp lars@ellebjerg.net
2017-01-05 00:00 ` Michael Paquier <michael.paquier@gmail.com>

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