i succesfully migrated an old script using tcl-sql to mysqltcl (and this post was extremely helpful in that migration.
now i'm wishing to go to the next step.
i want to catch exceptions.
say i want to delete something from the database. however, that deleted item does not exist to begin with. how would i handle that?
i'd want the eggdrop to catch this error and display the output to a channel.
Code: Select all
mysqlexec $mysql(conn) "delete from world where country = \"$country\"
if $country is not in the world table, then the database will process the information as such:
Query OK, 0 rows deleted.
how can i actually validate this output?
this basically leads me to trying to get the script to just find out what happens to the database afterwards. i know that in tcl-sql, i used something along these lines:
Code: Select all
set verifydelete [ catch {
sql exec $conn "delete from world where country = \"$country\"
} msg]
if { $verifydelete != 0 } {
putserv "PRIVMSG $chan :ERROR when deleting country!"
}
else
{
# all is good here, no need to have an else statement
}
this doesn't work with mysqltcl. this is also a problem when inserting duplicate entries into the database; i wish to display the output that there's a duplicate entry:
Code: Select all
set verifyinsert [ catch {
sql exec $conn "insert into world set country = \"$country\"
} msg]
if { $verifyinsert != 0 } {
putserv "PRIVMSG $chan :ERROR $msg when inserting country!"
}
else
{
# all is good here, no need to have an else statement
}
thanks!