RODBC sqlSave在插入查询中没有引用一些字符串

时间:2014-07-30 01:47:07

标签: sql r ms-access rodbc

我尝试使用sqlSave函数将data.frame的行插入Microsoft Access数据库的表中。首先,如果我没有指定fast = FALSE,我会收到致命错误,R和RStudio完全崩溃,没有给出错误消息。快速更改为FALSE修复此问题,但我收到错误

unable to append to table ‘archiverapp_fcsfiles’ 
sqlSave conn matched archiverapp_fcsfiles TRUE TRUE FALSE TRUE FALSE

通过设置verbose = TRUE,我可以看到它正在尝试做什么:

Query: INSERT INTO "archiverapp_fcsfiles" ( "experiment", 
                                            "fcsfilename", 
                                            "celltype", 
                                            "donor", 
                                            "time", 
                                            "readout", 
                                            "treat1", 
                                            "treat1conc", 
                                            "treat2", 
                                            "treat2conc", 
                                            "treat3", 
                                            "treat3conc" ) 
       VALUES ( 2, 'Specimen_001_F10_F10_JUN s63_60 minutes.fcs', 'Donor 1', 
               'THP1', TNFa, '50', '60', NULL, NULL, NULL, NULL, JUN s63 )
sqlwrite returned 
42000 -3100 [Microsoft][ODBC Microsoft Access Driver] 
Syntax error (missing operator) in query expression 'JUN s63'.
[RODBC] ERROR: Could not SQLExecDirect 
'INSERT INTO "archiverapp_fcsfiles" ( "experiment", "fcsfilename", "celltype",
   "donor", "time", "readout", "treat1", "treat1conc", "treat2", "treat2conc", 
   "treat3", "treat3conc" ) 
 VALUES ( 2, 'Specimen_001_F10_F10_JUN s63_60 minutes.fcs', 'Donor 1', 
   'THP1', TNFa, '50', '60', NULL, NULL, NULL, NULL, JUN s63 )'

正如您所看到的,它并没有在字符串周围添加引号' TNFa'和' JUN s63'。

我的任何其他查询都没有这样的问题,但是我再也没有使用fast = FALSE,所以它可能使用不同的方法。

关于如何避免这种情况的任何想法?

0 个答案:

没有答案