From: | "Daniel Kirkwood" <dmk(at)worfie(dot)net> |
---|---|
To: | "David Wheeler" <david(at)wheeler(dot)net>, <pgsql-general(at)postgresql(dot)org> |
Cc: | <dbi-users(at)perl(dot)org> |
Subject: | Re: NULL vs. Empty String |
Date: | 2001-03-14 06:48:02 |
Message-ID: | 002e01c0ac52$b9318560$170c0b0a@cairo.iteru.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Could it be as simple as:
$sth = $dbh->prepare("INSERT INTO table (row1, row2) VALUES (?, ?)");
if ( $webinput eq "" ) { $webinput = undef ; }
$sth->execute($webinput, $otherstuff);
I don't have Postgres here to test on, but inserting an undef should
translate to a NULL on most any DBD.
Regards,
Daniel.
----- Original Message -----
From: "David Wheeler" <david(at)wheeler(dot)net>
To: <pgsql-general(at)postgresql(dot)org>
Cc: <dbi-users(at)perl(dot)org>
Sent: Wednesday, March 14, 2001 2:26 PM
Subject: NULL vs. Empty String
Hi All,
Apologies for cross-posting.
I've ported a mod_perl application from Oracle to PosgreSQL, but have run
into a difference that's significant for web work. When I get a form field
submitted, if it's empty, mod_perl assumes it to be an empty string ('').
When I inserted empty strings into Oracle tables, Oracle assumed they were
NULL and inserted them as such. Postgres, OTOH, seems to insert it as an
empty string instead. While I realize that the Posgres interpretation is
perhaps the more precise of the two, it was a feature of Oracle that I
rather liked.
Is there a way to get Posgres to assume that a '' insert should be a NULL
insert? And if not, does anyone know of a way to get mod_perl to make that
assumption instead?
TIA,
David
From | Date | Subject | |
---|---|---|---|
Next Message | Daniel Kirkwood | 2001-03-14 06:50:17 | Re: NULL vs. Empty String |
Previous Message | Oliver Elphick | 2001-03-14 06:47:59 | Re: Fw: Please Help |