Skip to content

why querying Sybase IQ using RODBC returns error ?

3 messages · Jadhav, Alok, Brian Ripley

#
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.
#
This is a known bug in Sybase's ODBC driver, and yes, the workarounds 
are documented in the package.  Have you actually read the documentation?
On 30/07/2012 05:51, Alok Jadhav wrote:

  
    
#
Thanks Prof Ripley. I found the workaround quickly. I had read the
documentation while searching for connection string but did not look for
below specific issue. Lesson learnt.

Regards,
Alok


-----Original Message-----
From: Prof Brian Ripley [mailto:ripley at stats.ox.ac.uk] 
Sent: Monday, July 30, 2012 3:05 PM
To: Jadhav, Alok
Cc: r-help at r-project.org
Subject: Re: [R] why querying Sybase IQ using RODBC returns error ?

This is a known bug in Sybase's ODBC driver, and yes, the workarounds 
are documented in the package.  Have you actually read the
documentation?
On 30/07/2012 05:51, Alok Jadhav wrote:
package.
IQ};UID=ajadhav2;PWD=*****;ServerName=PSGSESHR01A_IQ;CommLinks=SharedMem
ory,TCPIP{host=psgseshr01_iq.sg.csfb.com;port=3051}"
buffsize,
'order' on
syagprd1.order
buffsize,
while I
http://r.789695.n4.nabble.com/why-querying-Sybase-IQ-using-RODBC-returns
-error-tp4638297.html
http://www.R-project.org/posting-guide.html