[R] RODC-Connection to more than one file

Wolf, Michael michael.wolf at bezreg-muenster.nrw.de
Tue Mar 19 08:26:02 CET 2002


Hallo everyone!

Has anyone an idee to get out data of more than one Excel-file via RODBC
with one single sqlQuery-command? The RODBC-manual shows how the sql command
shoot run, but every time I try, I got an error, that the ODBC-connection to
one of the files was not successful. If I make a sqlQuery for only one file
(e. g. in DatAllg.XLS without variables from DatBev.XLS / b. ...), the
ODBC-connection works fine.
Do I need a second channel? If so, how can I use two odbcConnect's in one
sqlQuery?

Here ist my R-source code:

>library(Rodbc)
># Specified Excel files in ODBC as User DSN:   DatAllg.XLS -> area name:
ALLG
>#                                              DatBev.XLS  -> area name:
BEV
># Sheets:                                      DatAllg.XLS -> ALLG
>#                                              DatBev.XLS  -> BEV
>channel <- odbcConnect("DatAllg")
>tt1 <- sqlQuery(channel, "select b.REGCODE, a.NAME, b.JAHR, b.BEV_G from
ALLG as a,  `C:/Arbeit/Database/Daten.DatBev`.BEV as b where ((a.REGCODE =
b.REGCODE) and (b.REGCODE>=5500000  and b.REGCODE<5700000)) order by
b.REGCODE, b.JAHR")
>odbcClose(channel)
>print(tt1)

If my code is too complicated please show me another example with two Excel
files.

Thank you for your help!

With best regards

Dr. Michael Wolf
Bezirksregierung Münster
Dezernat 61
Domplatz 1-3    48143 Münster
Tel.: +49 (0251) 411-1795            
Fax:  +49 (0251) 411-1751
Mail: michael.wolf at bezreg-muenster.nrw.de
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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