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.
Prof Brian Ripley
2012-Jul-30 07:04 UTC
[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:> 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. > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595