Re: Question about Oracle compatibility - Mailing list pgsql-hackers

From Alex Perel
Subject Re: Question about Oracle compatibility
Date
Msg-id Pine.BSF.4.10.10011271358500.10460-100000@rodent.webhosting.com
Whole thread Raw
In response to Re: Question about Oracle compatibility  (Don Baccus <dhogaza@pacifier.com>)
List pgsql-hackers
On Mon, 27 Nov 2000, Don Baccus wrote:

> >Actually, they aren't the same at all under Oracle or under Postgres.
> >
> >A null represents a lack of data, whereas an empty string is represents
> >data of zero length and zero content. Null is a state and not a value.
> 
> Unfortunately Mario's entirely correct (I use Oracle...)
> 
> insert into foo (some_string) values ('');
> 
> will insert a NULL, not an empty string, into the column some_string.

I stand corrupted. I didn't remember this behavior. :/
> >What you are probably seeing is a difference in table layout that sets
> >a default value of '' for the particular column you're touching. You can 
> >have postgres do the same by specifying DEFAULT '' when you create your
> >table (or you could ALTER it in..).
> 
> Using "DEFAULT ''" might help some, but he specifically mentioned inserting
> form data from a web page, and in this case he'll have to check the string
> and explicitly insert NULL (or write a trigger for each table that does
> the check and the resulting massage of the value) or rewrite his queries
> to treat empty string as being the same as NULL explicitly.

Might be easiest to feed the data through a simple stored proc. Doesn't take
long at all to whip something together for the purpose..

--      Alex G. Perel  -=-  AP5081
veers@disturbed.net  -=-  alex.perel@inquent.com              play  -=-  work                       
Disturbed Networks - Powered exclusively by FreeBSD
== The Power to Serve -=- http://www.freebsd.org/     



pgsql-hackers by date:

Previous
From: Don Baccus
Date:
Subject: Re: Question about Oracle compatibility
Next
From: Tom Lane
Date:
Subject: Re: Indexing for geographic objects?