Skip site navigation (1) Skip section navigation (2)

COPY with default values won't work?

From: Charles Tassell <ctassell(at)isn(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: COPY with default values won't work?
Date: 1999-03-24 05:15:37
Message-ID: 4.1.19990324005400.00950450@mailer.isn.net (view raw or flat)
Thread:
Lists: pgsql-general
I'm trying to copy data into the following table:

CREATE SEQUENCE seq_account_type_ndx;

CREATE TABLE accounts (
        Account_Type_NDX        int4 not null default
nextval('seq_account_type_ndx'),
        Account_Name            Text
);

Using this as a datafile:
\N|Box
\N|NetSurfer120
\N|eMailer
\N|eMailerLite

I've tried writing the code in C using libpq, using the copy command as the
postgres super user, or using \copy as my normal user.  NONE will work with
the "not null" in there, and if I remove it, it just inserts a null value
into account_type_ndx, without using the default.  I've also tried
switching the default to a number (ie default 12) instead of the nextval of
the sequence, with no better luck.

Here is the copy command I tend to use:
COPY accounts from stdin USING delimiters '|'
or \COPY accounts from '/tmp/datafile.txt' USING delimiters '|'

Any ideas?


Responses

pgsql-general by date

Next:From: Vadim MikheevDate: 1999-03-24 05:24:22
Subject: Re: [GENERAL] COPY with default values won't work?
Previous:From: Marcin GrondeckiDate: 1999-03-24 03:11:54
Subject: Re: [GENERAL] Restore deleted records

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group