Subject Re: [firebird-support] Problem in INSERT query
Author HJ
Adriano wrote:
> Hi,
> Firebird 2 RC1 Windows, Driver ODBC, Visual Basic
> I've a table FATTURE with some fields,
> a field named IDFATTURA which is Primary Key (not null, unique and active)
> a autoincremental trigger in Before Insert
> BEGIN
> IF (NEW.IDFATTURA IS NULL) THEN
> NEW.IDFATTURA = GEN_ID(GEN_FATTURE_IDFATTURA, 1);
> END
>
May be IDFATTURA field is set to zero at your client application. Try
add more check to your before insert trigger:

IF ((NEW.IDFATTURA IS NULL) OR (NEW.IDFATTURA = 0)) THEN
NEW.IDFATTURA = GEN_ID(GEN_FATTURE_IDFATTURA, 1);
END

HTH,
HJ