Plankton has asked for the wisdom of the Perl Monks concerning the following question:
When I execute execMonks.pl the second time I want to suppress the error message if the table REQUEST already exist. I don't want to supress failures for other types of errors. Any help would be appreciated :)bash-2.03$ cat execMonks.pl #!/usr/local/bin/perl -w use strict; use DBI; my $dbh = DBI->connect("dbi:SQLite:dbname=request_db","",""); my $createTableSQL = <<SQL; CREATE TABLE REQUEST ( REQ NUMBER, STATUS NUMBER ) SQL my $sth = $dbh->prepare( $createTableSQL ) or die $dbh->errstr . "\n"; $sth->execute() or warn $dbh->errstr . "\n"; $sth->finish; bash-2.03$ ./execMonks.pl bash-2.03$ ./execMonks.pl DBD::SQLite::st execute failed: table REQUEST already exists at ./exec +Monks.pl line 15. table REQUEST already exists
| Plankton: 1% Evil, 99% Hot Gas. |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How should I handle $sth->execute() errors?
by mifflin (Curate) on Dec 03, 2003 at 18:29 UTC | |
|
Re: How should I handle $sth->execute() errors?
by Abigail-II (Bishop) on Dec 03, 2003 at 18:10 UTC | |
|
Re: How should I handle $sth->execute() errors?
by mpeppler (Vicar) on Dec 03, 2003 at 18:18 UTC | |
|
Re: How should I handle $sth->execute() errors?
by Art_XIV (Hermit) on Dec 03, 2003 at 19:39 UTC | |
by jeffa (Bishop) on Dec 04, 2003 at 00:05 UTC | |
by Art_XIV (Hermit) on Dec 04, 2003 at 16:36 UTC |