APM: Perl vs Micorsoft SQL 7

Goldilox Goldilox at teachnet.edb.utexas.edu
Fri Mar 28 12:50:32 CST 2003


Microsoft SQL7 database. I have various cells in the database that are set to

NULL

(I had to spend a lot of time tracking them down to find what was causing the
warnings)

This one works the best so far, but still gives an uninitialized variable
warning when a NULL is encountered:

while(my @newdata = $newsth->fetchrow_array()){
print "Before: $newdata[1] - $newdata[2]\n";
$newdata[1] = "N/A" if $newdata[1] eq "";
$dataone=$newdata[1];
$newdata[2] = "N/A" if $newdata[2] eq "";
$datatwo=$newdata[2];
$newdata[3] = "N/A" if $newdata[3] eq "";
print "After: $newdata[1] - $newdata[2] - $newdata[3]\n";
$datathree=$newdata[3];
$htmldata=$htmldata.qq~<tr><td>$dataone</td><td align="right">$datatwo</td><td
align="right">$datathree</td></tr>~;
}

I have tried:

1)
$newdata[3] = "N/A" if undef $newdata[3];


2)
$newdata[3] = "N/A" if $newdata[3] eq "NULL";#(OK, this was dumb - but I wanted
to say I tried it)


3)
and I have tried: $newsth->fetchall_arrayref (with appropriate trappings)


No matter what, I get an uninitialized variable warning whenever there is a
database cell designated as NULL. I need the script to run without these
warnings appearing.
(the reason I need the warnings to disappear is: I want to use Perl for
database needs, currently some Frontpage generated ASP code is being used, and
the error handling of the ASP detects these NULL fields - I need Perl to run
just as cleanly because the folks who maintain the ASP code don't want me using
Perl since they only know ASP - it's a weird situation, I know, but I want to
show Perl can do the job just as cleanly, but I haven't been able to do that
yet)

Help?

Rhett




More information about the Austin mailing list