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

From: Shridhar Daithankar <shridhar_daithankar(at)myrealbox(dot)com>
To: "Nagib Abi Fadel" <nagib(dot)abi-fadel(at)usj(dot)edu(dot)lb>, "generalpost" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Should we consider empty fields as NULL values when dealing with string columns ?
Date: 2003-12-11 15:00:15
Message-ID: 200312112030.15560.shridhar_daithankar@myrealbox.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

On Thursday 11 December 2003 20:06, Nagib Abi Fadel wrote:
> 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)

No. Because an empty string is not null.

If you want it to work the way you describe, I believe you need to set
transform_null_equals to true in postgresql.conf

Check if postgresql7.3.2 supports it. But remember, relying on this variable
is not recommended. Probably you should use indicator variables if php
supports it.

HTH

Shridhar

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Greenwich Support 2003-12-11 15:02:41 Weird Problem With PostgreSQL 7.3.1 and VB.Net Datagrid
Previous Message Adrian Klaver 2003-12-11 14:59:08 Re: Storing Snapshot Data

Browse pgsql-hackers by date

  From Date Subject
Next Message Manfred Koizar 2003-12-11 15:14:43 Re: [GENERAL] Transaction Question
Previous Message Dave Page 2003-12-11 14:52:43 Re: [HACKERS] Should we consider empty fields as NULL values when dealing with string columns ?