I am trying to insert values from a select query using this:
INSERT INTO cb (vol_sec)
SELECT sum(vol)
FROM cb
GROUP BY cusec;
but the error message is ERROR: the value null for column «id» restriction violates not null. I have tried to change NOT NULL to NULL but i have another message 'The column <> is in the primary key. Is there any way to avoid this errors?.Thanks in advance.
idcolumn which is a primary key (henceNOT NULL), but doesn't have a default value. You probably need to add a sequence (or use an existing one if appropriate) and set theDEFAULTforidto grab the next value of that sequence. But of course, the exact details of your database schema and/or the way you use that table may have an influence on what exactly you should be doing.