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,);
In reply to eval doesn't work under tkx by nyj
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |