Re: [R] RODBC

From: Duncan Murdoch <murdoch_at_stats.uwo.ca>
Date: Wed 24 Jan 2007 - 23:08:16 GMT

On 1/24/2007 3:25 PM, jgaseff wrote:
> Hello,
>
> I am fairly new to R and its connectivity to MS-Access. I just installed
> RODBC and it seems to be working well except when I use the date to
> condition the query. For example the query below
>
> sqlQuery(channel, "select date from tblUScpi where (date > d2) order by
> date")
>
> returns the following error
>
> [1] "[RODBC] ERROR: Could not SQLExecDirect"
> [2] "07001 -3010 [Microsoft][ODBC Microsoft Access Driver] Too few
> parameters. Expected 1."
>
> I checked that d2 and the elements in date belong to the same class
> ("POSIXt" "POSIXct"). Can anybody help me?

If d2 is an R variable, you'll need to convert it to SQL syntax for dates (whatever that is, format() can probably do it). R just passes the query string to the database, it doesn't do any variable substitutions for you.

Duncan Murdoch



R-help@stat.math.ethz.ch 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. Received on Thu Jan 25 15:50:14 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 25 Jan 2007 - 05:30:29 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.