RODBC error: SqlSave unable to append to table

走远了吗. 提交于 2019-12-11 13:04:45

问题


we hit to an error with RODBC and SqlSave command. We are a bit confused what to do since the same SqlSave command works when data that we are trying to save to Sybase database is small (~under 10.000 rows). When trying to save bigger data (~200.000 rows) saving process starts without any problems but it crashes after few thousand rows is saved. Then we hit to this error message “unable to append to table..”

We use this kind of code:

library(RODBC)

channel <- odbcConnect("linfo-test", uid="DBA", pwd="xxxxxx", believeNRows=FALSE)

sqlSave(channel=channel, dat=matkat, tablename = "testitaulu", append = TRUE)

odbcClose(channel)

If someone has any idea why this happens only with bigger data and how we could fix this, we would be extremely grateful. We are lacking ideas ourselves.


回答1:


sqlSave with append=TRUE pretty much never works. You will have to explicitly write an SQL INSERT INTO statement, which is unfortunate. Sorry for the bad news.




回答2:


sqlSave is working but you have to be really careful with it. You need to remember:

  • in R column names of your data frame and sql server table have to match EXACTLY and remember that R is case sensitive, even leading space or space at the end can make a difference
  • make sure that your data types in R and sql table are matching
  • that you are not missing any column to insert( even it is default in sql)
  • connection have to be set up properly, if sql user doesn't have permission to read and write in a destination table(used in sqlSave) it can also fail


来源:https://stackoverflow.com/questions/36913664/rodbc-error-sqlsave-unable-to-append-to-table

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!