我们最近在安装gdata包时,与DB2/AS400的ODBC连接出现了大量问题。之后,我们对所有与R相关的文件进行了核处理,并重新开始,但IBMDB2连接仍然存在问题。如果。Rprofile加载我们的DBS odbc连接空白,没有错误(在R之外工作良好(。如果我在中写了什么。导致错误的Rprofile—与DB2/AS400的ODBC连接在DBI/ODBC和旧的ROBC中都能正常工作。DB2/AS400的底层CCSID为278。
编辑:我可以建立连接,但对象显示为空。对于DBI,我添加了CCSID=1252,并使其工作。但ROBC还没有这样的运气(即使我们计划离开它,我们仍在使用(
初始化过程中可能出现的问题是,只有当我在中插入错误时,它才起作用。Rprofile?如何在ROBC中指定编码以使其工作?
编辑2:问题出现在R中,因为ODBC连接在所有其他域中都可以工作
DBI/odbc-执行工作:
library(DBI)
library(odbc)
con3 <- dbConnect(odbc::odbc(), "mydb", uid= "myuser", pwd = "mypwd",
CCSID = 1252)
Rodbc-不工作:
con3 <- odbcConnect(dsn=mydb,uid= myuser,mypwd,
DBMSencoding = "1252")
会话信息:
version 4.2.0 Patched (2022-05-12 r82348 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19044)
Matrix products: default
locale:
[1] LC_COLLATE=Swedish_Finland.1252 LC_CTYPE=Swedish_Finland.1252 LC_MONETARY=Swedish_Finland.1252
[4] LC_NUMERIC=C LC_TIME=Swedish_Finland.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] odbc_1.3.3 DBI_1.1.3
loaded via a namespace (and not attached):
[1] bit_4.0.4 compiler_4.2.0 ellipsis_0.3.2 cli_3.4.1 hms_1.1.2 tools_4.2.0
[7] Rcpp_1.0.9 bit64_4.0.5 vctrs_0.4.2 blob_1.2.3 lifecycle_1.0.3 pkgconfig_2.0.3
[13] rlang_1.0.6
DBI/odbc的答案是设置CCSID=1252,而ROBC的答案则是设置Sys.setenv(NLS_LANG="LATIN1"(
它使。Rprofile加载很慢,但它可以工作,所以至少有。