zentara has asked for the wisdom of the Perl Monks concerning the following question:
Anyways, what I need to do is test my sql statement in a prepare statement, and stop executing the Tk callback if an error is raised. The error is plainly raised, but I can't seem to figure out how to have it set a flag, so I can return out of the callback before executing the sql.
When I enter a malformed sql statement in the above, I get the following printed to STDOUT. But the $@ is never caught in the eval, and it continues on as if there was no error.$entrysql->bind('<Return>',[sub { $sql = $entrysql->get; my $sth; eval {$sth = $dbh->prepare("select $mainstr from info $sql") or warn DBI::errstr $!; $sth->finish; }; if ($@){ print "ERROR - $@\n"; print chr(07); return; } .......continue to execute the sql }
DBD::SQLite::st execute failed: near "=": syntax error at ./ztkdb12a l +ine 664. Tk::Error: dbih_setup_fbav: invalid number of fields: 0, NUM_OF_FIELDS + attribute probably not set right at ./ztkdb12a line 668. <Key-Return> (command bound to event)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: $DBI::errstr and Tk:Error
by jeffa (Bishop) on Mar 11, 2004 at 18:03 UTC | |
|
Re: $DBI::errstr and Tk:Error
by Roy Johnson (Monsignor) on Mar 11, 2004 at 18:22 UTC | |
|
Re: $DBI::errstr and Tk:Error
by zentara (Cardinal) on Mar 12, 2004 at 01:03 UTC | |
|
Re: $DBI::errstr and Tk:Error
by zentara (Cardinal) on Mar 11, 2004 at 19:42 UTC |