0

This is a follow-up question to: Error in running R script in cmd window

I am still getting errors, but I switched from 64bit to 32bit R, and I think I am closer now, so I was hoping the following would jog someone's memory or tinfoil :)

Anyway, the paradox is that the following code runs instantly INSIDE of R :

library(RODBC) myconn <- odbcConnect("****", uid = "*******", pwd = "*******") test <- sqlQuery(myconn, "select * from tableAXd") close(myconn) summary(test)

But the very same code (in bat_test.R), sourced from a .bat file with this code:

C:\Users\********\Documents\R\R-3.3.1\bin\Rscript.exe  "C:\schedule\bat_test.R"

generates the following error in the cmd window:

[RODBC] ERROR: state IM104, code 0, message [Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and the Application...

So, why would the exact same code run sweetly from R, but choke on ODBC from a .bat file?

Thanks for listening... isotope

7
  • What database are you connecting to? Commented Nov 16, 2016 at 20:27
  • Oracle 10i if I'm not mistaken, is that what you are looking for? I pixelled out all of the info I could get fired for revealing :) Commented Nov 16, 2016 at 20:43
  • Is that the only line in .bat file? What happens if you run that one line in CMD prompt or PowerShell? Commented Nov 16, 2016 at 20:59
  • I ran it in cmd window directly, and got exactly same error :( Good idea tho. Sorry, I'm not familiar with PowerShell. And yes, that's all that's in the .bat file, outside of a PAUSE command to keep the window up. Commented Nov 16, 2016 at 21:09
  • Parfait, Just tried the .bat with and without lib.loc=. Either way it recognized RODBC fine (with the warning that RODBC was built under 3.3.2). I also thought that since I'm running 3.3.1, the 3.3.2 build of RODBC might be a problem, but as I said the code runs fine from inside R. Super ideas tho, exactly the kind of error logic testing I'm not really good at. Commented Nov 16, 2016 at 22:11

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.