But if what you want to get (and print) is "", would this (using NVL
in the select statement) work? Or would "" returned from the database
get interpreted by the DBI (or maybe by Perl itself) as undef?
Here's my clunky workaround for avoiding warnings about undef values (when
I don't want to just say "no warnings 'uninitialized';" in that block):
while ( $sth->fetch )
{
for my $each ( $field1, $field2 ) #-- any fields I'm fetching that might be null
{
$each ||= "";
}
print OUT join "|", ( $field1, $field2, $field3 ), "\n";
}
Mitch Helle-Morrissey's idea seems much more elegant.
--
David Dierauer
Database Programmer
CoreComm
On Fri, 4 Jan 2002, Morris Paterson wrote:
> why not use a NVL in your select staetment?
>
> Mitch Helle-Morrissey wrote:
>
> > Is there any way to have DBI return NULL database values as something other
> > than Perl undef? It's a pain if you're printing out a bunch of columns
> > without examining the values because printing an undef generates warnings.
> > I wrote my own function to map undefs to something else, but I was thinking
> > it would be nice to have an attribute of how NULL database values will be
> > returned to Perl. Maybe something like:
> >
> > $dbh->{NULL_VALUE} = '';
> > $dbh->{NULL_VALUE} = 'NULL';
> > $dbh->{NULL_VALUE} = undef; # current behavior