db.function | R Documentation |
Register functions with a database connection
db.function(db, NAME, FUN)
db |
The database connection. S4 object of class "database". |
NAME |
The name to register the function under. |
FUN |
The function to register. |
Functions registered with a database connection can be referred to by NAME in SQL statements. To unregister a function NAME, pass NULL as the FUN argument. See examples.
None.
A current limitation is that arguments to functions inside SQL statements can only be referred to by position. In other words, constructs like argname=argvalue will not work.
db = db.open()
db.function(db, "multiply", `*`)
db.eval(db, "CREATE TABLE t(a REAL, b REAL)")
db.eval(db, "INSERT INTO t VALUES (?,?)", matrix(rnorm(200), 100, 2))
db.eval(db, "SELECT multiply(a, b) FROM t", df=TRUE)
db.function(db, "multiply", NULL)
## Not run:
db.eval(db, "SELECT multiply(a, b) FROM t") # no such function: multiply
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.