[R] RODBC: Minor problem, I hope.

Shawn Way sway at tanox.com
Wed Nov 14 19:14:25 CET 2001


Sorry for the numerous posts, I found that an old (~ June) post had the same
title and confused me (and the list server) greatly (and made it hard to get
this as a new thread).

Anyway...

I'm trying to get the RODBC package to work with a MS Sql database
(Wonderware's InSQL).  I'm able to connect to the database using the
following:

version
         _                           
platform i386-pc-mingw32             
arch     x86                         
os       Win32                       
system   x86, Win32                  
status   Under development (unstable)
major    1                           
minor    4.0                         
year     2001                        
month    10                          
day      29                          
language R                           
> library(RODBC)
library(RODBC)

> channel <- odbcConnect("SCADA2","ways1","LO&B*O",case="msaccess")
> channel
channel
[1] 0

And an abbreviated table list is:

...
25    Runtime                dbo                   AnalogHistory
TABLE
...

A abbreviated Column List is as follows:

> odbcColumns(channel,"AnalogHistory")
odbcColumns(channel,"AnalogHistory")
[1] 1
> sqlGetResults(channel)
sqlGetResults(channel)

  TABLE_CAT TABLE_SCHEM    TABLE_NAME   COLUMN_NAME DATA_TYPE TYPE_NAME
1   Runtime         dbo AnalogHistory      DateTime        11  datetime
2   Runtime         dbo AnalogHistory       TagName        12   varchar
3   Runtime         dbo AnalogHistory         Value         6     float
4   Runtime         dbo AnalogHistory       Quality        -6   tinyint
5   Runtime         dbo AnalogHistory QualityDetail         4       int
6   Runtime         dbo AnalogHistory      wwTagKey         4       int

...

When I try to query the table, I get:

> test <- sqlQuery(channel,"select DateTime, value from AnalogHistory
> where Tagname = 'a055-re-0020_ph_pv_flt' and DateTime >= 'nov 1, 2001 
> 2:00pm'")

> test
test
[1] "37000 201 [Microsoft][ODBC SQL Server Driver][SQL Server]Procedure
'sp_prepare' expects parameter '@stmt', which was not supplied."
[2] "[RODBC]ERROR: Could not SQLPrepare"                           

Any thoughts?                                                 

Shawn Way
Tanox, Inc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://stat.ethz.ch/pipermail/r-help/attachments/20011114/644d71e0/attachment.html


More information about the R-help mailing list