pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
NOT NULL and postgres 6.5.2
4+ messages / 4 participants
[nested] [flat]

* NOT NULL and postgres 6.5.2
@ 1999-10-16 18:10  Stephan Bauer <stephan_bauer@gmx.de>
  0 siblings, 2 replies; 4+ messages in thread

From: Stephan Bauer @ 1999-10-16 18:10 UTC (permalink / raw)
  To: pgsql-sql

Hello all,

I have an table like this:

CREATE TABLE anzeigen (
...

        name                    varchar(30) NOT NULL,
...
);

The following statement _will_ be inserted:

INSERT INTO anzeigen ( ... name ...) 
VALUES ( ..., '', ...);

What is my problem?

Thanks in advance

Stephan Bauer



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: [SQL] NOT NULL and postgres 6.5.2
@ 1999-10-16 18:48  Oliver Elphick <olly@lfix.co.uk>
  parent: Stephan Bauer <stephan_bauer@gmx.de>
  1 sibling, 0 replies; 4+ messages in thread

From: Oliver Elphick @ 1999-10-16 18:48 UTC (permalink / raw)
  To: Stephan Bauer <stephan_bauer@gmx.de>; +Cc: pgsql-sql

Stephan Bauer wrote:
  >Hello all,
  >
  >I have an table like this:
  >
  >CREATE TABLE anzeigen (
  >...
  >
  >        name                    varchar(30) NOT NULL,
  >...
  >);
  >
  >The following statement _will_ be inserted:
  >
  >INSERT INTO anzeigen ( ... name ...) 
  >VALUES ( ..., '', ...);
  >
  >What is my problem?
 
An empty string is not the same as null.  It is a real value whereas null
is an unknown/undefined/irrelevant value.

-- 
      Vote against SPAM: http://www.politik-digital.de/spam/
                 ========================================
Oliver Elphick                                Oliver.Elphick@lfix.co.uk
Isle of Wight                              http://www.lfix.co.uk/oliver
               PGP key from public servers; key ID 32B8FAA1
                 ========================================
     "But be ye doers of the word, and not hearers only, 
      deceiving your own selves."              James 1:22 





^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: [SQL] NOT NULL and postgres 6.5.2
@ 1999-10-17 15:58  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Stephan Bauer <stephan_bauer@gmx.de>
  1 sibling, 0 replies; 4+ messages in thread

From: Tom Lane @ 1999-10-17 15:58 UTC (permalink / raw)
  To: Stephan Bauer <stephan_bauer@gmx.de>; +Cc: pgsql-sql

Stephan Bauer <stephan_bauer@gmx.de> writes:
> CREATE TABLE anzeigen (
> ...
>         name                    varchar(30) NOT NULL,
> ...
> );

> The following statement _will_ be inserted:

> INSERT INTO anzeigen ( ... name ...) 
> VALUES ( ..., '', ...);

> What is my problem?

An empty string '' is quite different from a NULL.

If you want to forbid empty strings you could add a constraint
expression, eg, CHECK (name <> '').

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: [SQL] NOT NULL and postgres 6.5.2
@ 1999-10-18 13:47  Mark Wright <mwright@pro-ns.net>
  0 siblings, 0 replies; 4+ messages in thread

From: Mark Wright @ 1999-10-18 13:47 UTC (permalink / raw)
  To: pgsql-sql

From: Oliver Elphick <olly@lfix.co.uk>
To: Stephan Bauer <stephan_bauer@gmx.de>
Cc: pgsql-sql@postgreSQL.org <pgsql-sql@postgreSQL.org>
Date: Saturday, October 16, 1999 1:58 PM
Subject: Re: [SQL] NOT NULL and postgres 6.5.2


>Stephan Bauer wrote:
>  >Hello all,
>  >
>  >I have an table like this:
>  >
>  >CREATE TABLE anzeigen (
>  >...
>  >
>  >        name                    varchar(30) NOT NULL,
>  >...
>  >);
>  >
>  >The following statement _will_ be inserted:
>  >
>  >INSERT INTO anzeigen ( ... name ...)
>  >VALUES ( ..., '', ...);
>  >
>  >What is my problem?
>
>An empty string is not the same as null.  It is a real value whereas null
>is an unknown/undefined/irrelevant value.


Stephan, I bet you're coming from the Oracle world, where '' is the same as
NULL.

(No lie.  Check this out:

    SQL> create table test_null (id number, name varchar(20) not null);

    Table created.

    SQL> insert into test_null values (1, '');
    insert into test_null values (1, '')
                *
    ERROR at line 1:
    ORA-01400: cannot insert NULL into ("SYSTEM"."TEST_NULL"."NAME")

This little bug can be _really_ irritating.

Mark.






^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~1999-10-18 13:47 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-10-16 18:10 NOT NULL and postgres 6.5.2 Stephan Bauer <stephan_bauer@gmx.de>
1999-10-16 18:48 ` Oliver Elphick <olly@lfix.co.uk>
1999-10-17 15:58 ` Tom Lane <tgl@sss.pgh.pa.us>
1999-10-18 13:47 Re: [SQL] NOT NULL and postgres 6.5.2 Mark Wright <mwright@pro-ns.net>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox