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
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'))
FROM '/data/Excel1.csv'
DELIMITERS ',' CSV;
Any help would be appreciated. Rich
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER