problem with inserting a generated seq no into not null field

From: mike <mike(at)bristolreccc(dot)co(dot)uk>
To: pgsql-general(at)postgresql(dot)org
Subject: problem with inserting a generated seq no into not null field
Date: 2004-06-08 11:37:48
Message-ID: 1086694668.31284.18.camel@datacc
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I have the following generic query which I am trying to use to insert
into a 3 field table

INSERT INTO tb_files (subj, area, file_no) select '4', '8',(SELECT CASE
WHEN (4||8) NOT IN (SELECT (subj||area) FROM tb_files) THEN '1' ELSE
max(file_no)+1 END FROM tb_files GROUP BY (subj||area),subj,area HAVING
subj = '4' AND area = '8');

However the first entry will not go in with a

'null value in column "file_no" violates not-null constraint'

message

Anyone any ideas on this - the CASE statement does not seem to be being
evaluated

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Holger Klawitter 2004-06-08 12:17:57 Index on points
Previous Message Jim Seymour 2004-06-08 10:43:47 Re: encrypted passwords