Hi,| > What is the solution of other dbs ( oracle, db2 .. ) to:| > insert into table (num) value (''); ? | | I assume
theywould fail too.
The Oracle behaviour is:
---
oracle> create table foonum (x number(5));
oracle> insert into foonum values ('');
oracle> select * from foonum;
--------+ X |
--------+[NULL] |
--------+
---
so, '' as numeric value is regarded as NULL. But Oracle
braindeadly interprets the varchar '' as well as NULL in a varchar
column so is probably not paragon ...
IMHO, if PostgreSQL is to support an empty string for numerics at all,
then it should be interpreted as not-a-value and as such as NULL.
Interpreting it as numeric value '0' could lead to subtle bugs since this
would probably not the expected behaviour (at least not mine).
The number '0' is arbitrary, except that we happend to start counting with
it. Someone else could argue why not interpret not-a-value as '1'
(non-computer guys tend to start counting with '1') or even '42' (since
this is the answer to everything).
I personally would be prefer to raise an error on an empty string; but
interpreting it as NULL would be reasonable as well. But interpreting it
as '0' will yield many unseen programming errors and should be avoided.
my 2cent,-hen