Re: dynamic crosstab - Mailing list pgsql-general

From Andy Colson
Subject Re: dynamic crosstab
Date
Msg-id 4B62FB5E.4020306@squeakycode.net
Whole thread Raw
In response to Re: dynamic crosstab  (Pierre Chevalier <pierre.chevalier1967@free.fr>)
List pgsql-general
On 1/28/2010 5:51 PM, Pierre Chevalier wrote:
>>
>> while ( my @list = $get->fetchrow_array)
>> {
>> print join(',', @list), "\n";
>> }

> It throws some insulting messages, though:
>
> Use of uninitialized value $list[5] in join or string at
> ./crosstab_perl.pl line 24.
> Use of uninitialized value $list[6] in join or string at
> ./crosstab_perl.pl line 24.
> Use of uninitialized value $list[7] in join or string at
> ./crosstab_perl.pl line 24.

Yeah, you can ignore them.  Fields that are null in the database will be
converted to undef in perl, which when printed spits out that warning.
Right before the print, we could test for undef and set them to empty
string like:

map { if (!defined($_)) {$_ = '';}} @list;

so the while loop would look like:

while ( my @list = $get->fetchrow_array)
{
    map { if (!defined($_)) {$_ = '';}} @list;
    print join(',', @list), "\n";
}

-Andy

pgsql-general by date:

Previous
From: Dave Page
Date:
Subject: Re: [pgsql-www] Versions RSS page is missing version(s)
Next
From: Devrim GÜNDÜZ
Date:
Subject: Re: [pgsql-www] Versions RSS page is missing version(s)