Yeah! I've missed the default option. But is this SQL standard?
And it does not seem to work for me at all. I still can't differ empty and NULL;
create table deftest (k integer primary key, i integer default 'NULL', s char default 'NULL');
sqlite> insert into deftest (i, s) values (NULL,''); sqlite> select * from deftest; 1|| sqlite>
So we are able to create empty values and NULL by an INSERT. Why shouldn't we a simple way to get it back by an SELECT too?
AlthoughTcl itself has no NULL value it would be nice to define a string that is given back by sqlite itself in cases where NULL values exist.
I am still hoping there is something usable and/or configurable like
PRAGMA null_string='NULL';
or
PRAGMA null_string='NAN';
which can be set before executing a select statement.
Regards
Kurt Welgehausen wrote:
Is there a way to change the NULL representation ... ?
No. Tcl has no null value. Usually this is not a problem, but if you really need to distinguish between a missing value and an empty string, you can use default values.
sqlite> create table deftest (k integer primary key,
...> i integer default '?',
...> s char default '??');
sqlite> insert into deftest (i) values (11);
sqlite> insert into deftest (i, s) values (22, '');
sqlite> select * from deftest;
k i s ---------- ---------- ----------
1 11 ?? 2 22
Regards