mysql - How to use paste function and quotes, in a for loop and insert statement -


through for loop r language, i'm trying use insert statement save rows in table: 1 row example looks :

numpat   name       firstnam     birthdate     sex    datprel      adicap1   idpat   numerorum   1       eloste      james      2003-09-27      1    2008-03-24    bhote4p1   468        2 

what i've tried write is:

 info<- paste("insert tab_anapath_std1 values (",matop[i,1],", \",matop[i,2],\",\",matop[i,3], \",",matop[i,4],",",matop[i,5],",",matop[i,6],",\",matop[i,7],\",",matop[i,8],",",matop[i,9],")")  sql_update_tbl_ds <- fn$dbsendquery(dbconn, info) 

and output got :

 numpat   name       firstnam       birthdate     sex    datprel      adicap1      idpat     numerorum    1    ,matop[i,2],    ,matop[i,3],    0000-00-00    1    0000-00-00   ,matop[i,7],    468       2 

i have real problem manage quotes ; i've tried change without success; how may write please ?

if using fn$ there no need use paste. fn$ alternative paste. write out string , wherever want insert r code surround r code backticks. here self contained example of using fn$ making use of built in bod data frame.

library(sqldf) matop <- matrix(1:4, 1, 4) <- 1  sql <- "select * bod time = `matop[i, 4]`"  fn$identity(sql) ## [1] "select * bod time = 4"  fn$sqldf(sql) ##   time demand ## 1    4     16 

Comments

Popular posts from this blog

php - Zend Framework / Skeleton-Application / Composer install issue -

c# - Better 64-bit byte array hash -

python - PyCharm Type error Message -