1

I am importing from the GUI a CSV file into a table. I have created the following table:

CREATE TABLE jira_tickets.daqa_rpt_tbl
(
 daqa_report_id bigint NOT NULL DEFAULT 'jira_tickets.daqa_id_seq'::regclass,
 project_name character varying(250) NOT NULL,
 jira_key character varying(250) NOT NULL,
 jira_summary text NOT NULL,
 issue_type character varying(100) NOT NULL,
 jira_status character varying(100) NOT NULL,
 jira_resolution character varying(250),
 jira_assignee character varying(250) NOT NULL,
 jira_reporter character varying(250) NOT NULL,
 jira_created text,
 jira_last_viewed text,
 jira_updated text,
 jira_resolved text,
 last_updated timestamp without time zone DEFAULT now(),
 CONSTRAINT "daqa_report_id_PK" PRIMARY KEY (daqa_report_id)
);

Error Message

When I import I get this error. Clearly the sequence is not incrementing when I move to the next row. Here is how I declare the sequence:

 CREATE SEQUENCE jira_tickets.daqa_id_seq
 INCREMENT 1
 MINVALUE 1
 MAXVALUE 1000000000000000000
 START 1
 CACHE 1;
ALTER TABLE jira_tickets.daqa_id_seq
 OWNER TO postgres;
GRANT ALL ON TABLE jira_tickets.daqa_id_seq TO public;
GRANT ALL ON TABLE jira_tickets.daqa_id_seq TO postgres;

Any suggestions or trouble shooting would be greatly appreciated.

Erwin Brandstetter
186k28 gold badges463 silver badges636 bronze badges
asked Jun 5, 2014 at 2:09
1
  • If your CSV import supplies a value for the daqa_report_id then that won't increment the sequence. You need to manually adjust the sequence after such an import. Search for "setting sequence value in postgres" Commented Jun 5, 2014 at 6:17

1 Answer 1

1

The column default for daqa_report_id would have to be:

nextval('jira_tickets.daqa_id_seq'::regclass)

Not:

(削除) 'jira_tickets.daqa_id_seq'::regclass (削除ここまで)

That would just fetch the OID for the sequence object from pg_class, which is converted to a meaningless, static bigint number.

pgAdmin has nothing to do with this.

But just use the pseudo data type bigserial instead. It does everything automatically. Here's how you would add a bigserial to an existing table:
Most efficient way to add a serial column to a huge table

answered Jun 5, 2014 at 7:51
1
  • Thank you! Yep that did it. How I was importing the data was my only point for mentioning pgAdmin. Commented Jun 5, 2014 at 10:05

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.