Link to home
Create AccountLog in
Avatar of RichardH1976
RichardH1976

asked on

Postgrece - Copy Command and Sequence Number

Hi,

I have created a copy from a CSV File into my database as as below.

COPY TEST (changed, changed, remove, description)
FROM '/data/Excel1.csv'
DELIMITERS ',' CSV;

The import is obviously failing because I have a primary key called Name which I would like to retrieve the next ID from "requestnextid" from the sequences....   I have tried adding this into the above like below but I get a syntax error.
(The import does work when I hard code the ID.)

COPY TEST (changed, changed,name (nextval('requestnextid')) ,remove, description)
FROM '/data/Excel1.csv'
DELIMITERS ',' CSV;

Any help would be appreciated.   Rich
ASKER CERTIFIED SOLUTION
Avatar of earth man2
earth man2
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of RichardH1976
RichardH1976

ASKER

This worked.  Thanks for your help.