List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:January 8 2003 2:44am
Subject:Re: Re: Using Perl DBI quote() method with NULL values?
View as plain text  
Date: Wed, 8 Jan 2003 01:56:39 +0100
From: mysql@stripped
To: Paul DuBois <paul@stripped>
Subject: Re:  Re: Using Perl DBI quote() method with NULL values?

At 17:16 -0500 1/7/03, walt wrote:
>Jeff,
>I'm not sure if this will help or not, but we ended up adding our
>own version of
>quote to
>perl cgis. Someone told me when I ask a similar question to check the value
>before calling
>quote, but it seemed like more of a headache... You may have to use
>perl's ord &
>chr to look for
>\n
>
>walt
>
>sub nea_quote
>{
>   my ($input) = @_;
>   if (length($input) == 0)
>   {
>    $return_string = "NULL";
>    return $return_string;
>   }
>   else
>   {
>    $return_string = $dbh->quote($input);
>    return $return_string;
>   }
>}

This seems unnecessary, and (unless I'm missing something), it seems
to treat empty strings as NULL, which isn't necessarily correct.

Just use DBI's quote() method, and pass it undef when you want to produce
a NULL.


sql, query
Thread
Re: Re: Using Perl DBI quote() method with NULL values?Paul DuBois8 Jan