Stavros Macrakis-2 wrote:
>
> What is the recommended way of checking whether an RODBC connection is
> open?
>
> Since odbcValidChannel is not exported from namespace RODBC, I suppose I
> shouldn't be using it.
>
> This is the best I could come up with, but it seems a bit 'dirty' to be
> using a tryCatch for something like this:
>
> odbcOpenp <- function(conn)
> tryCatch({odbcGetInfo(conn);TRUE},error=function(...)FALSE)
>
Directly after an open, testing for class of the channel should work. As I
understand ODDBC, there is no way of testing if the channel "is still open"
other than doing a test-read, because the other side could be connected
transatlantic. I remember an IBM memo giving an example that sends a
passthrough SQL query to the remote site.
Dieter
library(RODBC)
channel = odbcConnectAccess("db.mdb")
str(channel)
class(channel)
channel = odbcClose(channel)
str(channel) # Still of class RODBC, evidently
--
View this message in context:
http://www.nabble.com/RODBC-package%3A-how-to-check-whether-connection-is-open-tp23771854p23774853.html
Sent from the R help mailing list archive at Nabble.com.
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.