gmSQLValues: Format vector in parenthesis and SQL quote it

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/Database.R

Description

Formats values for use in SQL statements

Usage

1

Arguments

v

The values to be converted, could be dataframe, numeric vector or something convertable to a character vector.

quote

Logocical value defining if the given values shall be quoted.

db

The database connection for which the transformation shall be done. Currently only mysql is supported.

Details

The functions currently use dbEscapeStrings and are therefor only reliable with RMySQL-Connections.

Value

gmSQLValues A single string containing an SQL representation of the vector for use with the IN operator.

Author(s)

K. Gerald van den Boogaart

See Also

gmEscapeStrings

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
## Not run: 
.gmDB <- dbConnect(...)
complexString <- "He said: \"I\'m going to the circus\"\n"
cat(complexString)
gmEscapeStrings(complexString)
cat(gmEscapeStrings(complexString),"\n")
cat(gmSQLValues(complexString),"\n")
myfactor <- factor(c("a","a","b"))
cat(gmSQLValues(myfactor),"\n")
num <- 1:3
cat(gmSQLValues(num),"\n")

X <- data.frame(string=rep(complexString,3),fac=myfactor,x=num)
cat(gmSQLValues(X),"\n")

## End(Not run)

gmDatabase documentation built on May 2, 2019, 9:31 a.m.