Subject | seems bug : Field accepts NULL Values (empty string) even if it is defined with not null constraints ?? |
---|---|
Author | Kamlesh |
Post date | 2004-03-16T09:51:54Z |
dear friends
with following (field GROUPNAME defined with not null constraint)
CREATE TABLE GROUPINFO
(
GROUPNAME VARCHAR(50) NOT NULL UNIQUE,
PARENTID INTEGER NOT NULL,
GROUPCODE VARCHAR(50)
)
when i insert or update following triger executes
CREATE TRIGGER BT_GROUPINFO FOR GROUPINFO ACTIVE BEFORE INSERT OR UPDATE
POSITION 0 AS
BEGIN
/* if a value of GROUPNAME is only spaces i.e. ' ';
/* in following code after using trim function, new value will be ''
(empty string) */
IF (INSERTING OR UPDATING) THEN
New.GroupName = LTrim(New.GroupName); /* here it becomes '' empty
string*/
END^
after executing above trigger the value of GROUPNAME will be " empty string
( NULL) but it still allows and does not generate any error, and table is
now having a row having GROUPNAME as NULL ( field was defined with NOT NULL
constraint)
any idea
Thanks
Kamlesh
with following (field GROUPNAME defined with not null constraint)
CREATE TABLE GROUPINFO
(
GROUPNAME VARCHAR(50) NOT NULL UNIQUE,
PARENTID INTEGER NOT NULL,
GROUPCODE VARCHAR(50)
)
when i insert or update following triger executes
CREATE TRIGGER BT_GROUPINFO FOR GROUPINFO ACTIVE BEFORE INSERT OR UPDATE
POSITION 0 AS
BEGIN
/* if a value of GROUPNAME is only spaces i.e. ' ';
/* in following code after using trim function, new value will be ''
(empty string) */
IF (INSERTING OR UPDATING) THEN
New.GroupName = LTrim(New.GroupName); /* here it becomes '' empty
string*/
END^
after executing above trigger the value of GROUPNAME will be " empty string
( NULL) but it still allows and does not generate any error, and table is
now having a row having GROUPNAME as NULL ( field was defined with NOT NULL
constraint)
any idea
Thanks
Kamlesh