我现在用的是RODBCext包和RODBC包。如果我用这个代码存储过程的工作原理来执行使用R.在SQL Server 2008的存储过程。
query <- "EXEC [dbo].[usp_SchoolMerge] @Number = ?,
@Name = ?,
@Type = ?,
@Comments = ?,
@DualEnrollment =?,
@CEP = ?,
@DistrictGuidId = ?,
@ImportName = ?,
@ImportID = ?"
query <- gsub("[[:space:]]+", " ", query)
con2 <- odbcConnect("database", uid="userid", pwd="password")
for(i in 1:nrow(us11_12_00_school)) {
sqlExecute(con2, query, us11_12_00_school[i,])
}
odbcClose(con2)
如果我尝试使用量化的形式解释这里 2.3.2下使用参数化查询。
query <- "EXEC [dbo].[usp_SchoolMerge] @Number = ?,
@Name = ?,
@Type = ?,
@Comments = ?,
@DualEnrollment =?,
@CEP = ?,
@DistrictGuidId = ?,
@ImportName = ?,
@ImportID = ?"
query <- gsub("[[:space:]]+", " ", query)
con2 <- odbcConnect("database", uid="userid", pwd="password")
sqlExecute(con2, query, us11_12_00_school)
odbcClose(con2)
我得到R.这个错误
Error in sqlExecute(con2, query, us11_12_00_school) :
24000 0 [Microsoft][ODBC SQL Server Driver]Invalid cursor state
[RODBCext] Error: SQLExecute failed
如果我使用一个数据帧只有一行的量化代码工作。 还有其他人有这个问题吗? 有任何想法吗?