我正在访问商业数据库。通过提示:RODBC返回0值
select PersonCode, PersonDate from CODB.mastertable where PersonCode=42
PersonCode PersonDate
----------- ------------
42 Jan 3 2011
42 Jan 3 2011
42 Jan 3 2011
42 Jan 3 2011
42 Jan 3 2011
42 Jan 3 2011
42 Jan 3 2011
42 Jan 3 2011
42 Jan 3 2011
42 Jan 3 2011
在R:
library(RODBC)
query <- "select PersonCode, PersonDate from CODB.mastertable where PersonCode=42"
connection1 <- odbcConnect("RESDB", uid="userID", pwd="pwdaccess", believeNRows=FALSE)
sqlQuery(connection1,query)
sqlQuery(connection1,query)
PersonCode PersonDate
1 42 01/03/2011 00:00:00.000 UTC
2 42 01/03/2011 00:00:00.000 UTC
3 42 01/03/2011 00:00:00.000 UTC
4 42 01/03/2011 00:00:00.000 UTC
5 42 01/03/2011 00:00:00.000 UTC
6 0 01/03/2011 00:00:00.000 UTC
7 0 01/03/2011 00:00:00.000 UTC
8 0 01/03/2011 00:00:00.000 UTC
9 0 01/03/2011 00:00:00.000 UTC
10 0 01/03/2011 00:00:00.000 UTC
查询的输出不正确。有没有人遇到过这个问题?这里有一些附加信息。
> sessionInfo()
R version 2.12.1 (2010-12-16)
Platform: x86_64-unknown-linux-gnu (64-bit)
locale:
[1] C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] timeDate_2130.92 data.table_1.5.3 RODBC_1.3-2
loaded via a namespace (and not attached):
[1] tools_2.12.1
?你是通过ODBC还是直接连接?使用R,你使用的是什么ODBC驱动程序?在使用64位Linux的RODBC中存在已知的错误,但当您应该获得NA(NULL数据)时,它们通常会给出0。我从来没有见过非NULL数据的腐败。 – Harlan 2011-05-10 21:01:55
我认为你的R安装(locale可能?)有一些非常时髦的事情。这看起来非常类似于[早期问题](http://stackoverflow.com/q/5915728/271616)。这是否发生在您之前的问题中显示的两种情况中? – 2011-05-10 21:05:12
@harlan 1. sqsh,或者也叫dbvis的前端。其他用户使用其他应用程序获得相同的结果。 2.如何告诉正在使用的ODBC驱动程序?我想提供这些信息。 @joshua不,这不是我昨天遇到的问题。虽然我必须说,在3次罢工后,我可能不得不将一些关键代码移到Python中。我不能承受错误。 – gappy 2011-05-10 21:12:08