Re: NULL value question



On Jul 31, 3:04 pm, Jim James <j...@xxxxxxxxxxxxx> wrote:
I'm coding my first web site using a mysql
database and DBI.

I can fetch records from the database
with no problem, but I'm having trouble
testing NULL values. If I load the value
of a date field into a variable ($dateadded),
how should the IF condition be written?

if (!defined $dateadded) {

I found some information that talked
about NULLs being undef, but I'm
not sure how to use that information.

perldoc -f defined
perldoc -f undef

Note if the value in your DB isn't actually NULL, but is instead the
empty string, you'll have to specifically compare to the empty string:
if ($dateadded eq "") {

Paul Lalli

.



Relevant Pages

  • problem using table_info and column_info with DBD::Proxy
    ... print STDERR Dumper; ... It works with a direct database connection. ... # Testing problem with LISTFIELDS and column_info ...
    (perl.dbi.users)
  • Re: Sacred EIAS
    ... Most databases make a distinction between a null value and an empty ... a database API that returned the result of a query as a list. ... One can't use an empty string because that would be indistinguishable ... An empty string is of course a legitimate and useful value - and Tcl ...
    (comp.lang.tcl)
  • Re: Sacred EIAS
    ... Most databases make a distinction between a null value and an empty ... a database API that returned the result of a query as a list. ... One can't use an empty string because that would be indistinguishable ... An empty string is of course a legitimate and useful value - and Tcl ...
    (comp.lang.tcl)
  • Re: leading spaces
    ... box has a value of "", which is an empty string, not null. ... >I have a connection to SQL Server and have setup a customer profile page ... > update statement runs adds leading spaces to the database. ...
    (microsoft.public.frontpage.programming)
  • Re: problem using table_info and column_info with DBD::Proxy
    ... How would you recommend connecting to a mysql database on a different machine? ... print STDERR Dumper; ...
    (perl.dbi.users)