[R] RODBC: closing databases
Renaud Lancelot
lancelot at sentoo.sn
Mon May 14 17:32:46 CEST 2001
Dear all,
platform i386-pc-mingw32
arch x86
os Win32
system x86, Win32
status
major 1
minor 2.3
year 2001
month 04
day 26
language R
I wrote the following to import tables in different database formats
(Access, Visual FoxPro, etc.):
getTable <- function(Type, Table){
if(!is.element("package:RODBC", search())){
cat("Loading RODBC package", "\n")
invisible(library(RODBC))
}
Channel <- odbcConnect(Type)
query <- paste("select * from", Table)
tab <- sqlQuery(Channel, query)
odbcClose(Channel)
tab
}
Then something like:
CaPds <- getTable(Type = "VFP", Table = "CaPds")
does the job: the data.frame is quickly and properly obtained. However,
when I go back to the database management system and try to update the
original table, I get an error message saying that I cannot access the
file. I have to close R to be able to update the table.
How do I close an open table ?
Best regards,
Renaud
--
Dr Renaud Lancelot, vétérinaire
CIRAD, Département Elevage et Médecine Vétérinaire (CIRAD-Emvt)
Programme Productions Animales
http://www.cirad.fr/presentation/programmes/prod-ani.shtml
ISRA-LNERV tel (221) 832 49 02
BP 2057 Dakar-Hann fax (221) 821 18 79 (CIRAD)
Senegal e-mail renaud.lancelot at cirad.fr
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list