Subject Re: [firebird-support] Why won't this work in Firebird?
Author Helen Borrie
At 11:42 PM 21/02/2005 -0700, you wrote:

>INSERT INTO CUSTOMER_TYPE (CUST_TYPE_COMPANY_ID, CUST_TYPE_DESC) values
>(1,'General') where not exists(SELECT CUST_TYPE_DESC from CUSTOMER_TYPE
>where CUST_TYPE_DESC = 'General');
>
>Any ideas?

It's not valid syntax? :-)) An insert doesn't know what's in the table
it's inserting to - it's inserting new data, so a search clause simply
isn't logical for an insert.

Instead, protect the CUST_TYPE_DESC column with a unique constraint. Then,
if someone tries to insert a second row with 'General' in CUST_TYPE_DESC,
you can pick it up as an exception and tell the user "Customer type General
already exists".

./heLen