Sign in with Microsoft
Sign in or create an account.
Hello,
Select a different account.
You have multiple accounts
Choose the account you want to sign in with.

嘗試使用在平行化的背景工作執行緒之間的多個 ODBC 連線可能會失敗,如下列範例所示︰

loaddata <- function(cn){
result <- sqlQuery(cn,'select * from boston')

return(head(result))

}

library(RODBC)

cn1 <- odbcConnect("RevoTestDB", uid='RevoTester', pwd='RevoTester')

cn2 <- odbcConnect("RevoTestDB", uid='RevoTester', pwd='RevoTester')

cn3 <- odbcConnect("RevoTestDB", uid='RevoTester', pwd='RevoTester')

cn4 <- odbcConnect("RevoTestDB", uid='RevoTester', pwd='RevoTester')

rxSetComputeContext('localpar')

system.time ({

z <- rxExec(loaddata, rxElemArg(list(cn1,cn2,cn3,cn4)), 
packagesToLoad='RODBC')

})

Error in do.call(.rxDoParFUN, as.list(args)) :

task 1 failed - "first argument is not an open RODBC channel"

問題在於背景工作處理序收到的 ODBC 連線關閉。

這裡的問題是連線會是特定處理序的所以工作者共用父處理序 (如所示建立透過分支多核心的工作者),除非父代的連線不能共用的工作人員。若要散發 ODBC 計算上非分叉工作者,建立上每個背景工作的連線為分散式工作的一部份。

範例︰

loaddata <- function(){library(RODBC)
cn <- odbcConnect("RevoTestDB", uid='RevoTester', pwd='RevoTester')
result <- sqlQuery(cn,'select * from boston')
return(head(result))
}

z <- system.time({z <- rxExec(loaddata,
packagesToLoad='RODBC')})


Need more help?

Want more options?

探索訂閱權益、瀏覽訓練課程、瞭解如何保護您的裝置等等。

社群可協助您詢問並回答問題、提供意見反應,以及聆聽來自具有豐富知識的專家意見。

Was this information helpful?

How satisfied are you with the translation quality?
What affected your experience?
By pressing submit, your feedback will be used to improve Microsoft products and services. Your IT admin will be able to collect this data. Privacy Statement.

Thank you for your feedback!

×