I have a function that catches errors resulting from odbcQuery
. How would one make it so that attempting to drop tables that don't exist does not throw an error?
The function:
runQuery <- function(script, channel, errors = T) {
run <- odbcQuery(channel, script)
# if the function has returned an error
if (run == -1L) {
if (errors) {
err <- odbcGetErrMsg(channel)
cat("\nobdcQuery() encountered an error running the following SQL ")
cat("query:\n\n", script, "\n\nError from Oracle server:\n")
return(err)
} else {
err <- invisible(run)
}
}
}