Should we consider empty fields as NULL values when dealing with string columns ?

From: "Nagib Abi Fadel" <nagib(dot)abi-fadel(at)usj(dot)edu(dot)lb>
To: "generalpost" <pgsql-general(at)postgresql(dot)org>, "developPost" <pgsql-hackers(at)postgresql(dot)org>
Subject: Should we consider empty fields as NULL values when dealing with string columns ?
Date: 2003-12-11 14:36:56
Message-ID: 001401c3bff4$49abd7f0$f664a8c0@nagib
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

HI,
let's say we have the following table :

# CREATE TABLE tempo (col1 varchar(3) not null);
CREATE TABLE

# insert INTO tempo VALUES ('');
INSERT 11420541 1

the insert command works.

The issue is that since the column col1 is defined as character with not null attribute,
shouldn't we deny such inserts (i mean inserting empty fields)???
(PS: i am using postresql 7.3.2)

When using script languages (like PHP) if by mistake the variable is not defined such insert is possible (let's say we have a variable $col1_value and after a long day of work we make a mistake and write it $col_value).

This "problem" is solved by adding the constraint:
ALTER TABLE tempo add constraint col1_check check(col1!='');

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Doug McNaught 2003-12-11 14:52:25 Re: Should we consider empty fields as NULL values when
Previous Message Tom Lane 2003-12-11 14:32:29 Re: Moving a database between servers

Browse pgsql-hackers by date

  From Date Subject
Next Message Doug McNaught 2003-12-11 14:52:25 Re: Should we consider empty fields as NULL values when
Previous Message Doug McNaught 2003-12-11 14:23:54 Re: PostgreSQL port to pure Java?