如何使用 DB2/AS400 通过 R ODBC 和 DBI 传递隔离级别

How to pass isolation level through R ODBC and DBI with DB2/AS400

我正在尝试找出一种通过 R DBI/ODBC 为 DB2/AS400 连接字符串传递隔离级别的方法。我什至不确定我的问题是否正确。

我可以使用下面 link 中的说明更改 Windows ODBC 服务器设置中的提交模式,但如果可能,我需要将设置放在连接字符串中。: https://www.ibm.com/support/pages/ibm-i-access-odbc-commit-mode-data-source-setting-isolation-level-and-autocommit

这是我们的 DBA 允许我们这些小数据科学家写入数据仓库的唯一方式。

当然必须有一种方法可以通过“*NONE”又名“立即提交(*NONE),但是 ODBC 文档(第 21 页)没有包括设置: https://cran.r-project.org/web/packages/odbc/odbc.pdf

连接字符串:

con <- DBI::dbConnect(odbc::odbc(),
                      SYSTEM = "system",
                      Driver    = "{iSeries Access ODBC Driver}", 
                      #Server    = "server",
                      #Database  = "",
                      UID       = "uid",
                      PWD       = rstudioapi::askForPassword("password"),
                      DBQ =   "MYLIB"
                      #Port      = 
                    
)

ISeries ODBC 驱动程序 API 文档: https://www.ibm.com/docs/en/i/7.4?topic=details-connection-string-keywords 向下到第二部分找到所有提交模式选项。

为了改变提交模式的连接字符串:

con <- DBI::dbConnect(odbc::odbc(),
                      SYSTEM = "system",
                      Driver    = "{iSeries Access ODBC Driver}", 
                      #Server    = "server",
                      #Database  = "",
                      UID       = "uid",
                      PWD       = rstudioapi::askForPassword("password"),
                      DBQ =   "MYLIB",
                      CMT = 0
                      #Port      = 
                    
)
Possible values:
0 = Commit immediate (*NONE)
1 = Read committed (*CS)
2 = Read uncommitted (*CHG)
3 = Repeatable read (*ALL)
4 = Serializable (*RR)