Page 1 of 1

NOTNULL accepting nulls?

Posted: Sat May 13, 2006 7:54 am
by GeXus
I set a column to not null, yet it is still accepting null values... is white space a value?

Posted: Sat May 13, 2006 9:08 am
by timvw
white space, "", " ", '', ' ' are not equal to NULL.



ps: Even NULL isn't equal to NULL ;)

Posted: Sat May 13, 2006 10:17 am
by GeXus
Ah I see.... is there a way to go about this?

Basically i'm using one page to add and update, so i have a select clause, and if column B doesnt exist, it will add.. or else it will update if it does exist.. the problem is that it is always seeing it as existing because it is creating empty space...

Posted: Sat May 13, 2006 10:24 am
by timvw
Handle it at the php side..

If strlen($input) == 0 -> generate query with NULL value , otherwise generate query with $input

Posted: Sat May 13, 2006 1:49 pm
by raghavan20
timvw wrote:Handle it at the php side..

If strlen($input) == 0 -> generate query with NULL value , otherwise generate query with $input

try a trigger before update on the column in the table and make empty values to NULL. It will be cool.

Posted: Sat May 13, 2006 6:07 pm
by timvw
Untill the day i really want to add just '' ;)

I appreciate that a dbms validates my data, but usually i do not appreciate when it decided to modify it..