Fetchrow Uninitialized Values
From: seldn (seldn_at_hotmail.com)
Date: 11/30/03
- Next message: Jason Dusek: "Pointers and References"
- Previous message: Drieux: "Re: Stupid Question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 30 Nov 2003 05:52:08 -0800
Hello all.
I have a script that connects to a PostgreSQL database, executes a
single SELECT, and dumps the results to the screen. Although it works
find, I am getting 'Uninitialized Values' warnings from those rows
that contain NULL values.
I'm aware that some rows will have NULL values but would rather not be
warned about it each time. I've been able to suppress these warnings
by encapsulating the array print in "no warnings;" and "use
warnings;". Is this the appropriate method of dealing with this, or
is there a better option? The code is below.
Thanks for the help,
Seldn
#-----------------------------------------------------
#!/opt/perl/bin/perl
use warnings;
use strict;
use DBI;
my $dbname="testdb";
my $dbh = DBI->connect("dbi:Pg:dbname=$dbname");
unless ($dbh) {die $DBI::errstr}
my $sql = "SELECT * FROM servers";
my $sth = $dbh->prepare("$sql");
unless ($sth) {die $DBI::errstr}
$sth->execute;
while (my @row = $sth->fetchrow()) {
no warnings;
print @row;
use warnings;
}
$sth->finish;
$dbh->disconnect;
- Next message: Jason Dusek: "Pointers and References"
- Previous message: Drieux: "Re: Stupid Question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|