As Joran mentioned in a comment this question is an sqldf FAQ. In fact its sqldf FAQ #8.
As discussed there the problem is that you asked to update the table but never asked it to return the table. Also $'contract'
should be '$contract'
since you want to substitute in contract
and then surround that substitution with single quotes.
# set up test data for reproduciblity
con <- data.frame(V1 = c("a", "b", "c"))
contract <- "a"
numbernew <- "x"
Now that we have some data try this:
sql1 <- fn$identity("update con set V1 ='%$numbernew%' where V1 = '$contract' ")
sql2 <- "select * from main.con"
sqldf(c(sql1, sql2))
The result is:
V1
1 %x%
2 b
3 c
This would work too:
sqldf() # start a sequence of SQL statements
fn$sqldf("update con set V1 ='%$numbernew%' where V1 = '$contract' ")
ans <- sqldf("select * from main.con")
sqldf() # SQL statements finished