Subject Re: NOT NULL constraint not being enforced by Firebird
Author dr_bentonquest
Hola Toño,

Sorry, I should have mentioned before that I added those 'not null'
fields to the table *after* the table was created. I used an ALTER
statement to add the fields. Do you think this affects the constraint
enforcement?

I have searched my application code and the database metadata looking
for 'insert into detallenom' and the procedure I quoted before is the
only place where new records are inserted into the table.

Like you, I am also puzzled to find 'null' values on those fields. I
understand that the problem might not be reproducible on your side,
but I could send you (or anyone) the gdb file so you can see the null
values in there. For me it's an eye-popping situation. I feel like
betrayed by Firebird :)

BTW, I could send you the gdb file but *not* the gbk file, as you
cannot restore it because the restore process tries to enforce the
'not null' constraint but it can't due to the null values, so the
restore is aborted.

Ideas, anyone?

Regards,

-Benton

--- In firebird-support@yahoogroups.com, "Antonio Galicia"
<antonio.galicia@...> wrote:
>
> On 6/9/06, dr_bentonquest <bentonquest@...> wrote:
>
> > Please note that the DEDXTRA and PERXTRA fields are not in the INSERT
> > field list. I tought they would receive the default value (a zero).
> > Instead, I get null values on them, which I can easily confirm
> > with a SELECT.
>
> Hi!
>
> I can't reproduce this error.
>
> > So, under which conditions would a 'not null' field accept null
> > values? Using FB 1.5.3 for Linux.
>
> I do this
> -----------------------------
> CREATE TABLE PRUEBA(
> ID INTEGER,
> TEXTO VARCHAR(5),
> DEDXTRA NUMERIC(9,2) DEFAULT 0 NOT NULL,
> PERXTRA NUMERIC(9,2) DEFAULT 0 NOT NULL
> );
>
> INSERT INTO PRUEBA (ID, TEXTO) VALUES (1, 'A');
> INSERT INTO PRUEBA (ID, TEXTO) VALUES (2, 'BB');
> INSERT INTO PRUEBA (ID, TEXTO) VALUES (3, 'CCC');
> INSERT INTO PRUEBA (ID, TEXTO) VALUES (4, 'DDDD');
>
> -----------------------------
>
> Then:
>
> SQL> select * from PRUEBA;
>
> ID TEXTO DEDXTRA PERXTRA
> ============ ===== ============ ============
>
> 1 A 0.00 0.00
> 2 BB 0.00 0.00
> 3 CCC 0.00 0.00
> 4 DDDD 0.00 0.00
>
> SQL> SHOW VERSION;
> ISQL Version: LI-V1.5.3.4870 Firebird 1.5
> Firebird/linux AMD64 (access method), version "LI-V1.5.3.4870
Firebird 1.5"
> on disk structure version 10.1
> SQL>
> -----------------------------
>
> --
> Saludos,
> Toño
> ----
> http://agc.com.mx/antoniogc/blog
>