On Wed, Feb 3, 2010 at 9:22 PM, Tony Esposito <tony1234567...@yahoo.co.uk> wrote: > This question has never been answered. To out it another way, given the code > ... > > foreach my $mytable (@mytables) { > my $sth = $dbh->prepare("SELECT COUNT(*) FROM mytable"); > # report error but move on to next table > } > > how do I ignore the situation/error that DBI throws when $mytable does not > exist and just move on to the next table? > > >
The question was answered, but perhaps you did not understand the answer: Wrap the call in an eval block. Then check $@ to see if there was a fatal error, which you can ignore if you want to or do something along the lines of: eval { my $sth = $dbh->prepare("SELECT COUNT(*) FROM mytable"); }; if ($@) { print "Table $table -- (probably) DOES NOT EXIST\n"; next; } $retCode = $sth->execute(); HTH, -- jay -------------------------------------------------- This email and attachment(s): [ ] blogable; [ x ] ask first; [ ] private and confidential daggerquill [at] gmail [dot] com http://www.tuaw.com http://www.downloadsquad.com http://www.engatiki.org values of β will give rise to dom! -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/