[R] why querying Sybase IQ using RODBC returns error ?

Alok Jadhav alok.jadhav at credit-suisse.com
Mon Jul 30 06:51:27 CEST 2012


Hello, 

 I am not able to query Sybase IQ database from R using RODBC package. 
Check the below code 

R> sybaseiq.query <- function (sql, ..., as.is = FALSE) 
{ 
  connstr <- "Driver={Sybase
IQ};UID=ajadhav2;PWD=*****;ServerName=PSGSESHR01A_IQ;CommLinks=SharedMemory,TCPIP{host=psgseshr01_iq.sg.csfb.com;port=3051}" 
  chan <- odbcDriverConnect(connstr) 
  on.exit(odbcClose(chan)) 
  if (length(list(...)) > 0) 
    sql <- sprintf(sql, ...) 
  x <- sqlQuery(chan, sql, as.is = as.is) 
  return(x) 
} 
R> 
R> 
R> 
R> x <- sybaseiq.query("select * from syagprd1.orders where
tradedate='120727' and acct='DVW'") 
Error in .Call(C_RODBCFetchRows, attr(channel, "handle_ptr"), max, buffsize, 
: 
  negative length vectors are not allowed
R> x 
[1] "42000 -131 [Sybase][ODBC Driver][Sybase IQ]Syntax error near 'order' on
line 1"                                                             
[2] "[RODBC] ERROR: Could not SQLExecDirect 'select * from syagprd1.order
where tradedate='120727' and acct='DVW' and ptag=-1 and sym='BHP.AX''" 


This is same behavior for empty datasets also 

R> x <- agora.query.iq("select * from syagprd1.orders where 1=2") 
Error in .Call(C_RODBCFetchRows, attr(channel, "handle_ptr"), max, buffsize, 
: 
  negative length vectors are not allowed 

I am not sure what is wrong. Are their some arguments I need to know while I
create chan to resolve this issue? 

Thanks for your help in advance. 

Regards, 
Alok 



--
View this message in context: http://r.789695.n4.nabble.com/why-querying-Sybase-IQ-using-RODBC-returns-error-tp4638297.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list