Hi,

correct sequence in this case is:

ALTER TABLE Defects ADD idDefectType TLongInt;

COMMIT;

UPDATE ...

COMMIT;

ALTER TABLE Defects ALTER idDefectType SET NOT NULL;

COMMIT;

The commits are necessary.

Slavek


>      
> hi,
> yes it is expected. you must:
> 1.add field with "default"
> or
> 2. add field without not nullupdate table and set that field valueafter that 
> change that field to not null
> regards,Karol Bieniaszewski
>
> -------- Oryginalna wiadomość --------
> Od: Slavomir Skopalik <skopa...@elektlabs.cz>
> Data: 12.10.2016  02:32  (GMT+01:00)
> Do: For discussion among Firebird Developers 
> <firebird-devel@lists.sourceforge.net>
> Temat: [Firebird-devel] FB3.0.1 - Impossible to alter table
>
> Hi all,
>
> If I have a table that contains some rows, in FB3.0.1 is not possible to
> add new NOT NULL column.
>
> Example:
>
> ALTER TABLE Defects ADD idDefectType TLongInt NOT NULL;
>
> COMMIT;
>
> Cannot commit transaction:
> unsuccessful metadata update.
> Cannot make field IDDEFECTTYPE of table DEFECTS NOT NULL because there
> are NULLs present.
>
> If I will try to set a value it will causes:
>
> ALTER TABLE Defects ADD idDefectType TLongInt NOT NULL;
> update Defects SET idDefectType=0;
>
> Dynamic SQL Error.
> SQL error code = -206.
> Column unknown.
> IDDEFECTTYPE.
> At line 1, column 20.
>
> Is it bug or is it expected?
>
> Slavek
>
>



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel

Reply via email to