pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Sumeet <asumeet@gmail.com>
To: Julian Scarfe <julian@avbrief.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: NULL becomes default
Date: Thu, 17 Aug 2006 14:22:03 -0400
Message-ID: <7539aebb0608171122n771f4862p4e2482aa2093b56b@mail.gmail.com> (raw)
In-Reply-To: <029c01c6c228$8e8e5210$0600a8c0@Wilbur>
References: <029c01c6c228$8e8e5210$0600a8c0@Wilbur>

Hi Julian u need to reset your sequence, i had run through the same problem.


On 8/17/06, Julian Scarfe <julian@avbrief.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.

view thread (5+ messages)  latest in thread

Message-ID: <7539aebb0608171122n771f4862p4e2482aa2093b56b@mail.gmail.com>
Permalink:  ../7539aebb0608171122n771f4862p4e2482aa2093b56b@mail.gmail.com/
Also on:    postgresql.org/message-id/7539aebb0608171122n771f4862p4e2482aa2093b56b@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: asumeet@gmail.com, julian@avbrief.com
  Subject: Re: NULL becomes default
  In-Reply-To: <7539aebb0608171122n771f4862p4e2482aa2093b56b@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox