Statement failed, SQLCODE = -625 validation error for column ID, value "*** null ***"


You might see this error whenever a NOT NULL column contains NULLs.

A particular case where it is hard to track is when you try to define PRIMARY KEY constraint, which requires that no record contains NULL. You might even issue statements like:

select * from table1 where pk is null;
update table1 set pk = 1 where pk is null;

Everything might look alright, but creating primary key would fail.

In such case, there is a good chance that you have some other user connected to the same database, running some transaction. This transaction might be too old to know about your update, and it would still see the old record versions that have NULLs in them. Creation of primary key works for everyone, so when Firebird tries to put those old records with NULLs into primary key index, the statement breaks.

In short: if you have a column that used to be nullable, and you turn it into NOT NULL, populate it with values and wish to create a primary key that includes it - make sure nobody else is running a transaction on the database. If you use Firebird 2.1 or above, you can check this easily via monitoring tables (just SELECT FROM MON$STATEMENTS)


Do you find this FAQ incorrect or incomplete? Please e-mail us what needs to be changed. To ensure quality, each change is checked by our editors (and often tested on live Firebird databases), before it enters the main FAQ database. If you desire so, the changes will be credited to your name. To learn more, visit our add content page.



All contents are copyright © 2007-2024 FirebirdFAQ.org unless otherwise stated in the text.


Links   Firebird   News   FlameRobin   Powered by FB: Home Inventory   Euchre  
Add content   About  

Categories
 Newbies
 SQL
 Installation and setup
 Backup and restore
 Performance
 Security
 Connectivity and API
 HOWTOs
 Errors and error codes
 Miscellaneous