nyj has asked for the wisdom of the Perl Monks concerning the following question:
If I invoke my program from the command line, this works fine, that is, if the table I'm trying to overwrite (an Access table) already exists, the 'eval' loop catches it and the table is dropped and the process continues. BUT . . . the user wanted it to be more GUI, so I wrote a Tkx thing, which includes this:# We put these next statements into a loop because we might encoun +ter an error # we can recover from. If so, the 'eval' will catch it and throw + it to 'if ($@)' while ($sqlSuccess == 0) { eval { $dbh->{RaiseError} = 1; $sth = $dbh->prepare($sqlStatement); $sth->execute(); print $fileHandle "rows affected - " . $sth->rows . "\n"; while (my @row=$sth->fetchrow_array()) { if (defined $queryFiles{$query}) { print queryLog "@row\n"; } $rowCount++; } $sqlSuccess = 1; }; if ($@) { print $fileHandle "caught error $@\n"; my $errString = $@; print $fileHandle "here err string is |$errString|\n"; if ($errString =~ m|Table '(.*)' already exists|) { print $fileHandle "got to here\n"; my $sql = "drop table " . $1; my $drop = $dbh->prepare($sql); $drop->execute(); } else { return "Error found - $errString"; } } }
When I use the 'Email3' button, the program goes ahead and does a whole bunch of work UNTIL it gets to the case where the table already exists, then it just bombs out and nothing I have tried so far catches the error "table already exists". I'm fresh out of ideas. Anyone know what to do about this? I'm running ActiveState (downloaded and installed this week) on Windows XP Pro, service pack 3.my $Email3; $Email3 = $mw->new_button( -text => "Email3", -command => [\&doTheWork,"Email3"], ); $Email3->g_pack(-padx=>10, -pady=>10,);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: eval doesn't work under tkx
by Corion (Patriarch) on Jul 15, 2010 at 20:28 UTC | |
by nyj (Novice) on Jul 15, 2010 at 22:14 UTC | |
|
Re: eval doesn't work under tkx
by shmem (Chancellor) on Jul 16, 2010 at 04:55 UTC | |
by nyj (Novice) on Jul 16, 2010 at 05:56 UTC | |
by shmem (Chancellor) on Jul 16, 2010 at 08:55 UTC | |
by nyj (Novice) on Jul 19, 2010 at 10:42 UTC | |
|
Re: eval doesn't work under tkx
by Gangabass (Vicar) on Jul 16, 2010 at 03:26 UTC | |
by nyj (Novice) on Jul 16, 2010 at 06:16 UTC | |
by Corion (Patriarch) on Jul 16, 2010 at 07:55 UTC | |
|
Re: eval doesn't work under tkx
by aquarium (Curate) on Jul 16, 2010 at 04:08 UTC | |
by nyj (Novice) on Jul 16, 2010 at 06:01 UTC |