Query Oracle DNS in RStudio

Viewed 339

I am using RStudio with package RODBC using the following code

require(RODBC)
channel<-odbcConnect(dsn = "USA", uid = "AA", pwd = "***" )
odbcGetInfo(channel)

This returns all the details but when I try and do a sql query

test<-sqlQuery(channel,"select * from cnty", rows_at_time = 1)

It returns an error with

Error in odbcFetchRows(channel, max = max, buffsize = buffsize, nullstring = nullstring,  : 
          negative length vectors are not allowed

This works if I open Microsoft AccessDB - External Data -ODBC DataBase - link to data source click machine Data Source and select the source which then allows me to do a select query.

I have also tried using

debug(odbcFetchRows) test<-sqlQuery(channel,"select * from cnty", rows_at_time = 1)

This returns

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)
}
1 Answers

I got this working by using test<-sqlQuery(channel,"select * from cnty", rows_at_time = 1,believeNRows = FALSE)

Related