Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Suppress the Bug

by artist (Parson)
on Jun 08, 2006 at 16:10 UTC ( [id://554313]=perlquestion: print w/replies, xml ) Need Help??

artist has asked for the wisdom of the Perl Monks concerning the following question:

I found a bug with DBD::AnyData and has been reported earlier. It displays unncessary warning. How do I suppress this bug in my code output ?
Update:
use DBI; use strict; my $dbh = DBI->connect('dbi:AnyData(RaiseError=>0):'); $dbh->func( 't_pricedata', 'Pipe', 'pricedata', { col_names => 'item,p +rice' }, 'ad_catalog' ); my $query = q(SELECT item,price FROM t_pricedata); my $sth = $dbh->prepare($query); $sth->execute(); while ( my $row = $sth->fetchrow_hashref ) { print $row->{price}, "\n"; } $sth->finish; $dbh->disconnect;
Thanks,
--Artist

Replies are listed 'Best First'.
Re: Suppress the Bug
by Limbic~Region (Chancellor) on Jun 08, 2006 at 16:33 UTC
    artist,
    As far as I can tell, this message is coming from DBI. You likely have a missing:
    $sth->finish;
    I am betting that the problem is not in either module but with your code. Feel free to share that since my crystal ball is in the shop.?

    Update: Now that you have added some code, it appears that DESTROY calls STORE('Active', 0) which is apparently failing. STORE() is inherited from DBD::File which passes it up to DBI. I do not know why this appears to be failing but it might help jZed in tracking it down. I also figured out through experimentation that the error doesn't happen if you don't actually execute the statement handle (i.e. access the file). Save extremely drastic measures, I am not sure how you would disable this warning.

    Cheers - L~R

Re: Suppress the Bug
by Tanktalus (Canon) on Jun 08, 2006 at 16:35 UTC

    First attempt. Since DBI.xs calls warn() to print out the complaint, perhaps catching it via $SIG{__WARN__} may help.

    Second attempt. Go into DBI.xs (part of the DBI distribution), comment out the warning, and recompile it.

    I'd try them in that order. ;-)

Re: Suppress the Bug
by ciderpunx (Vicar) on Jun 08, 2006 at 16:37 UTC
    Ummm it's not a good idea to "surpress warnings". You have been warned.

    Just redirecting stderr to /dev/null or NUL would do it. Or have it make an error log like:

    win32
    > perl my_code 2> log
    *nix
    $ perl my_code 2> log

    Another option is just commenting out the warn in the source.
      Ummm it's not a good idea to "surpress warnings". You have been warned.
      So now the _real_ question obviously becomes: how do I suppress people's warnings about "suppressing warnings" ? :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://554313]
Approved by Joost
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (4)
As of 2024-04-26 00:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found