我使用 RStudio 和 RODBC 包,使用以下代码
require(RODBC)
channel<-odbcConnect(dsn = "USA", uid = "AA", pwd = "***" )
odbcGetInfo(channel)
这会返回所有详细信息,但是当我尝试执行 sql 查询时
test<-sqlQuery(channel,"select * from cnty", rows_at_time = 1)
它返回一个错误
Error in odbcFetchRows(channel, max = max, buffsize = buffsize, nullstring = nullstring, :
negative length vectors are not allowed
如果我打开 Microsoft AccessDB - 外部数据 -ODBC 数据库 - 链接到数据源,单击计算机数据源并选择允许我执行选择查询的源,则此操作有效。
我也尝试过使用
debug(odbcFetchRows) test<-sqlQuery(channel,"select * from cnty", rows_at_time = 1)
这会返回
function (channel, max = 0, buffsize = 1000, nullstring = NA_character_,
believeNRows = TRUE)
{
if (!odbcValidChannel(channel))
stop("first argument is not an open RODBC channel")
.Call(C_RODBCFetchRows, attr(channel, "handle_ptr"), max,
buffsize, as.character(nullstring), believeNRows)
}
最佳答案
我通过使用 test<-sqlQuery(channel,"select * from cnty", rows_at_time = 1,believeNRows = FALSE)
得到了这个工作
关于r - 在 RStudio 中查询 Oracle DNS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47473579/