Copy and serial type problem

Started by Przemyslaw 'Morp][ik' Berlinskiover 24 years ago3 messagesgeneral
Jump to latest
#1Przemyslaw 'Morp][ik' Berlinski
morphik@irc.nospam.gdansk.pl

Hi,

I've created a small table:

CREATE TABLE "table" (
"id" int4 DEFAULT nextval('"table_idd_seq"') NOT NULL,
"file" character varying(40) NOT NULL
);

Table sequence 'table_idd_seq' is also available with a next id number.

Question is how to use postgres copy function with this 'id'. Table 'table'
is not empty... I've tried to insert nextval("table_idd_seq") into file but
it doesn't work.

Any help would be appreciated.

TIA
Morp][ik

#2Lee Harr
missive@frontiernet.net
In reply to: Przemyslaw 'Morp][ik' Berlinski (#1)
Re: Copy and serial type problem

On Sun, 22 Jul 2001 21:13:26 +0200, <morphik@irc.nospam.gdansk.pl>:

Hi,

I've created a small table:

CREATE TABLE "table" (
"id" int4 DEFAULT nextval('"table_idd_seq"') NOT NULL,
"file" character varying(40) NOT NULL
);

Table sequence 'table_idd_seq' is also available with a next id number.

Question is how to use postgres copy function with this 'id'. Table 'table'
is not empty... I've tried to insert nextval("table_idd_seq") into file but
it doesn't work.

Not sure how you can do this in one step, but you can create a
temporary table to hold the "file" data and copy in to that,
then INSERT ... SELECT that data in to "table".

#3Creager, Robert S
CreagRS@LOUISVILLE.STORTEK.COM
In reply to: Lee Harr (#2)
RE: Copy and serial type problem

You don't indicate how you're executing the copy. If you're using a
script/program, just add your own counter as the first field in the copy. I
do this 'all the time' from Perl scripts, and it works fine. If you're
using psql, I haven't a clue unless you massage the input data before doing
the copy.

Rob

Show quoted text

-----Original Message-----
From: Przemyslaw 'Morp][ik' Berlinski
[mailto:morphik@irc.nospam.gdansk.pl]
Sent: Sunday, July 22, 2001 1:13 PM
To: pgsql-general@postgresql.org
Subject: [GENERAL] Copy and serial type problem

Hi,

I've created a small table:

CREATE TABLE "table" (
"id" int4 DEFAULT nextval('"table_idd_seq"') NOT NULL,
"file" character varying(40) NOT NULL
);

Table sequence 'table_idd_seq' is also available with a next
id number.

Question is how to use postgres copy function with this 'id'.
Table 'table'
is not empty... I've tried to insert nextval("table_idd_seq")
into file but
it doesn't work.

Any help would be appreciated.

TIA
Morp][ik

---------------------------(end of
broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to
majordomo@postgresql.org)