From: | Sumeet <asumeet(at)gmail(dot)com> |
---|---|
To: | "Julian Scarfe" <julian(at)avbrief(dot)com> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: NULL becomes default |
Date: | 2006-08-17 18:22:03 |
Message-ID: | 7539aebb0608171122n771f4862p4e2482aa2093b56b@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Hi Julian u need to reset your sequence, i had run through the same problem.
On 8/17/06, Julian Scarfe <julian(at)avbrief(dot)com> wrote:
>
> A surrogate key has been introduced on a table with modifiers:
>
> Column | Type |
> Modifiers
>
> -------------+-----------------------------+------------------------------------------------------------
> new_id | integer | not null default
> nextval(('some_id_seq'::text)::regclass)
>
> However, some legacy software inserts into the table by first getting
> column
> names and then composing an INSERT for all the columns, filling in any
> undefined values with NULLs.
>
> Thus when it attempts to insert a row I get a:
>
> ERROR: null value in column "new_id" violates not-null constraint
To fix this, you need to do something like:
SELECT setval('public.fdata _fid_seq', max(fid)+1) FROM fdata;
This will make sure that the next *value* your *sequence* generates is
greater than any key that already exists in the table.
>> taken from tom lane.
--
Thanks,
Sumeet.
From | Date | Subject | |
---|---|---|---|
Next Message | Sumeet | 2006-08-17 20:37:03 | About DBlink |
Previous Message | Julian Scarfe | 2006-08-17 18:11:21 | NULL becomes default |