Insert this line below the fetchrow_array:

        foreach (@info) { $_ = 'NULL' unless defined $_ }
or
        defined($_) or $_ = 'NULL' foreach @info;

take your pick.

Then go read the DBI docs about how NULLs are represented as undef values.

Tim.

On Tue, Feb 24, 2004 at 09:21:31AM -0700, McMahon, Chris wrote:
> 
> Hello... 
>       I'm a DBI newbie.  I've written a little script that reports the
> description of each column in a table.  The script works fine, but when it
> runs it reports warnings that I don't understand.  Here's the script: 
> ***********************************
> use warnings; 
> use DBI; 
> 
> <connect omitted>
> 
> my $sth1 = $dbh->table_info(); 
> while (my(@tab) = $sth1->fetchrow_array()) {
>       our @colNames; 
>       push @colNames, @tab[2];        
>       }
> 
> open OUT, ">col.txt";
> foreach $colName(@colNames) { 
> print OUT "$colName\n";
> my $sth = $dbh->column_info(); 
>       while (my(@info) = $sth->fetchrow_array()) {    
>               if ($colName eq @info[2]) {
>               print OUT "[EMAIL PROTECTED]";  #WARNINGS FROM THIS LINE
>               } #END IF
>       }#END WHILE 
>       }#END FOREACH 
> 
> $dbh->disconnect; 
> **************************************************
> 
>       For each "@info" that gets printed, I get 4 or 5 instances of the
> warning "Use of uninitalized value in join or string..."  
>       Using Win32::ODBC, I would see these warnings on a SELECT when the
> row contained NULL values, but I'm not understanding what about using
> column_info is producing these warnings.  I'm hoping someone on this can
> educate me a bit... 
>       Thanks-
> -Chris   

Reply via email to