Skip to content

Interpolating variables within (RODBC library) SQL statements for MySQL

1 message · Gabor Grothendieck

#
x <- 1; y <- 2

# 1
paste("x is", x, "y is", y)

# 2
sprintf("x is %d, y is %d", x, y)

# 3
library(gsubfn)
fn$cat("x is $x, y is $y\n")

For the last one see http://gsubfn.googlecode.com
If we preface a function by fn$ then it interpolates
strings subject to some qualifications, e.g.

fn$sqlQuery(ch, "select * from myTable where pos1 = $x and pos2 = $y")


On Mon, May 25, 2009 at 4:26 PM, John Fitzgerald
<john.fitzgerald at internet.de> wrote: