Re: [SQL] Cannot insert dup id in pk

2003-07-15 Thread Scott Cain
On Tue, 2003-07-15 at 10:43, Dmitry Tkach wrote: > You must have your sequence out of date with the content of the table > (so that the next value in the sequence has already been inserted). > One way to get into a situation like that is loading the table data with > COPY (the input contains the

Re: [SQL] Cannot insert dup id in pk

2003-07-15 Thread Tom Lane
Scott Cain <[EMAIL PROTECTED]> writes: > Note that I do not try to insert anything into fid, the primary key on > this table. Why does Postgres think I am? But you *are* trying to insert something into fid, namely the default value: default nextval('public.fdata _fid_seq'::text) My guess

Re: [SQL] Cannot insert dup id in pk

2003-07-15 Thread Dmitry Tkach
You must have your sequence out of date with the content of the table (so that the next value in the sequence has already been inserted). One way to get into a situation like that is loading the table data with COPY (the input contains the pks, and the COPY command does not update the sequence,

Re: [SQL] Cannot insert dup id in pk

2003-07-15 Thread Henshall, Stuart - TNP Southwest
Title: RE: [SQL] Cannot insert dup id in pk I suspect the sequence is out of sync with the values actually in you primary key (which I gues is fid. Try this query SELECT setval('public.fdata _fid_seq'::text,MAX(fid)+1) FROM fdata; This should set the value of the sequence to t