Subject | Re: [firebird-support] seems bug : Field accepts NULL Values (empty string) even if it is defined with not null constraints ?? |
---|---|
Author | Martijn Tonies |
Post date | 2004-03-16T10:00:10Z |
Hi,
NULL is NULL (empty). An empty string is a value. NULL is a state,
so is "NOT NULL".
With regards,
Martijn Tonies
Database Workbench - developer tool for InterBase, Firebird, MySQL & MS SQL
Server.
Upscene Productions
http://www.upscene.com
> with following (field GROUPNAME defined with not null constraint)string
>
> 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
> ( NULL) but it still allows and does not generate any error, and table isNULL
> now having a row having GROUPNAME as NULL ( field was defined with NOT
> constraint)You're answering your own question: '' (empty string) is NOT NULL.
NULL is NULL (empty). An empty string is a value. NULL is a state,
so is "NOT NULL".
With regards,
Martijn Tonies
Database Workbench - developer tool for InterBase, Firebird, MySQL & MS SQL
Server.
Upscene Productions
http://www.upscene.com