APM: RE: Perl vs Micorsoft SQL 7

Jim Leonard jimleona at cisco.com
Sat Mar 29 08:04:37 CST 2003


You might try this to skip warning messages that popup ( here I detect a
duplicate entry in a primary key of a Mysql table and skip it cause I
don't want the program to die there ):

	# Ignore message "DBD::mysql::st execute failed: Duplicate
entry"
	$SIG{__WARN__} = sub { 
		warn $_[0] unless $_[0] =~ /^DBD::mysql::st execute
failed: Duplicate entry/ 
		};

HTH,

Jim


> -----Original Message-----
> From: austin-admin at mail.pm.org 
> [mailto:austin-admin at mail.pm.org] On Behalf Of Goldilox
> Sent: Friday, March 28, 2003 12:51 PM
> To: austin-pm at pm.org
> Subject: APM: Perl vs Micorsoft SQL 7
> 
> 
> 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
> 
> _______________________________________________
> Austin mailing list
> Austin at mail.pm.org
> http://mail.pm.org/mailman/listinfo/austin
> 




More information about the Austin mailing list