That is a good way to hide the warnings. Another reason that I'd like to be
able to specify what NULL comes out as is that I may want to display null
differently in different applications. For example, Sybase has bcp which is
a bulk upload utility. When I want to make bcp files, they are just
pipe-delimited text files with NULL fields represented by the absence of a
value:
1||Mitch|December
So in that case I might want to print out NULL values as "". But when I
print things for humans, (say a web entry screen), I'd rather see "NULL"
where a null value is.
1|NULL|Mitch|December
Certainly I could do this mapping myself, but I'd rather not do it every
place I fetch rows. Also, I'm sure it would be much more efficient for DBI
to handle it internally. Especially when we're talking about a lot of rows.
And it seems like it wouldn't be that difficult of a thing to add.
I suppose that undef is the only "safe" string to use because otherwise how
do you know if the actual value of the database field was the string "NULL"
or the value NULL that I chose to be represented by the string "NULL".
Mitch
> -----Original Message-----
> From: Ronald J Kimball [mailto:[EMAIL PROTECTED]]
> Sent: Friday, January 04, 2002 9:57 AM
> To: Mitch Helle-Morrissey
> Cc: [EMAIL PROTECTED]
> Subject: Re: mapping NULL values
>
>
> On Fri, Jan 04, 2002 at 09:17:28AM -0600, 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.
>
> You could turn off warnings locally when you use the values:
>
> {
> local $^W;
> print join ',', @values;
> }
>
> Or, if you have perl5.6:
>
> {
> no warnings 'uninitialized';
> print join ',', @values;
> }
>
> Ronald
>