Subject Re: Weird php and firebird problem, repeating values
Author Adam
--- In firebird-support@yahoogroups.com, Fabio Gomes <fabioxgn@g...>
wrote:
>
> Sorry guys about bothering you again, but..
>
> I ve re-created my database and i used DEFAULT NULL to create the
tables,
> but it seens that it still leave the data "blank" on the field, is there
> some way to write NULL in the field if i send a blank data? or i ll
have to
> change all my php code to send NULL instead of a empty data?
>
> Thanx.

The default value is only used when you do not provide a value, and
only during an insert operation.

create table t
(
a integer,
b varchar(10) default null
);

commit;

insert into table (a,b) values (1, '');
insert into table (a) values (2);
select * from t;

a b
== ==
1 ''
2 <null>

You have to forget everything you may have learnt about null = 0 or
null = empty string or null = some weird date.

NULL is a concept, not a value. (A bit like infinity in that regard).
NULL is synonymous with unknown, or undefined or not relevant.

A simple example is a persons middle name.

You may have a table of people, some have middle names that you know,
some you know have no middle name, and the rest may or may not have a
middle name.

Those who you know do not have a middle name should be given '' as
their middle name. But if you do not know their middle name or if they
have one, then use null, see the difference. NULL is a flag on the
fields value, not a value itself.

Have a good read of this document and you will see how it works and
will not be pulling out your hair over it.

http://firebird.sourceforge.net/pdfmanual/Firebird-Null-Guide.pdf

Adam