Subject | domain default value |
---|---|
Author | kaczy27 |
Post date | 2006-01-19T17:06:03Z |
Hi,
I have definde the domain as not null with default value. Like this:
CREATE DOMAIN MY_DOMAIN AS
SMALLINT
DEFAULT 0
NOT NULL
I have assumed that if I insert a new row providing null for the
field using this domain, the default value would used.
CREATE TABLE MY_TABLE (
ID INTEGER,
MY_FIELD MY_DOMAIN NOT NULL);
So I was quite surprised when following command exceptioned:
INSERT INTO MY_TABLE(ID, MY_FIELD) VALUES (10, NULL);
and had to workaround this by similiar construct.
if (field is null) then
INSERT INTO MY_TABLE(ID) VALUES (:ID);
else
INSERT INTO MY_TABLE(ID, MY_FIELD) VALUES (:id, :my_field);
end
question? is it correct? does anyone else feel this counter-
intuitive? is there a need for such explicit code?
CUIN Kaczy
I have definde the domain as not null with default value. Like this:
CREATE DOMAIN MY_DOMAIN AS
SMALLINT
DEFAULT 0
NOT NULL
I have assumed that if I insert a new row providing null for the
field using this domain, the default value would used.
CREATE TABLE MY_TABLE (
ID INTEGER,
MY_FIELD MY_DOMAIN NOT NULL);
So I was quite surprised when following command exceptioned:
INSERT INTO MY_TABLE(ID, MY_FIELD) VALUES (10, NULL);
and had to workaround this by similiar construct.
if (field is null) then
INSERT INTO MY_TABLE(ID) VALUES (:ID);
else
INSERT INTO MY_TABLE(ID, MY_FIELD) VALUES (:id, :my_field);
end
question? is it correct? does anyone else feel this counter-
intuitive? is there a need for such explicit code?
CUIN Kaczy