Alex Chelminsky
2010-Jan-24 20:30 UTC
[R] Setting thevalue of max in calls to sqlGetResults
I have compiled and linked a 64 bit version of R (R 2.9.2) and the corresponding unix ODBC 64 bit package When issuing a SqlQuery, I get the following error> library(RODBC) > channel <- odbcConnect("OraLSH", <user>, <password>) > sqlQuery(channel,"select sysdate from dual")Error in .Call(C_RODBCFetchRows, attr(channel, "handle_ptr"), max, buffsize, : negative length vectors are not allowed> close(channel) > q()I know I can replace the call to sqlQuery with calls to its component functions odbcQuery and sqlGetResults to get the same result (and the same error)> library(RODBC) > channel <- odbcConnect("OraLSH", <user>, <password>) > odbcQuery (channel, "select sysdate from dual") > sqlGetResults(channel, as.is=FALSE, errors=FALSE, max=0, buffsize=1,nullstring=NA, na.strings="NA", believeNRows=TRUE, dec=getOption("dec")) Which returns the same error, namely: Error in .Call(C_RODBCFetchRows, attr(channel, "handle_ptr"), max, buffsize, : negative length vectors are not allowed>However, if I modify the value of max=0 (which means there is no limit to the number of rows that can retrieved) to another value, the function returns the correct value:> library(RODBC) > channel <- odbcConnect("OraLSH", <user>, <password>)) > odbcQuery (channel, "select sysdate from dual") > sqlGetResults(channel, as.is=FALSE, errors=FALSE, max=1, buffsize=1,nullstring=NA, na.strings="NA", believeNRows=TRUE, dec=getOption("dec")) SYSDATE 1 2010-01-24 15:10:02>The issue is that, before issuing the query, I don't know how the size of the resulting data frame. My question is: Is there a way to obtain the value of the resulting data frame and using that as an argument to the max parameter? Alexander Chelminsky Principal CSC GBS | p: +1 781 290 1620 | f: +1 781 890 1208 | m: +1 617 650 5453 | achelminsky at csc.com | www.csc.com This is a PRIVATE message. If you are not the intended recipient, please delete without copying and kindly advise us by e-mail of the mistake in delivery. NOTE: Regardless of content, this e-mail shall not operate to bind CSC to any order or other contract unless pursuant to explicit written agreement or government initiative expressly permitting the use of e-mail for such purpose.
Possibly Parallel Threads
- Setting the value of max in calls to sqlGetResults
- Run time error when executing sqlQuery using the 64-bit version of R with 64-bit RODBC package in a Solaris 10 Sparc machine.
- why querying Sybase IQ using RODBC returns error ?
- RODBC & MS SQL Server: repeated calls to sqlGetResults() problem
- RODBC tables