r - 在 RStudio 中查询 Oracle DNS

标签 r dns rodbc

我使用 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/

相关文章:

sockets - 127.0.0.1 和 localhost 有什么区别

sql - RODBC 错误 : Could not SQLExecDirect

r - data.frame 中列的基于时间的平均(滑动窗口)

r - 子集数据框,其中日期在 R 中日期向量的 x 天内

python - dnspython动态更新PeerBadKey

excel - ROBDC SqlSave : How to export data into Excel sheets?

RODBC sqlSave() 和映射列名

r - 如何将引号粘贴到 R 中的字符串(在列中)?

r - 每个值每年的百分比

带路径的 Apache 虚拟主机