callFUNCTION {pgTools}R Documentation

Generate a PostgreSQL statement to execute a function, optionally execute the statement if con is not NULL.

Description

Generate a PostgreSQL statement to execute a function, optionally execute the statement if con is not NULL.

Usage

callFUNCTION(
  x = list(),
  schema = NULL,
  func,
  quote_text = TRUE,
  cast = TRUE,
  types,
  con = NULL
)

Arguments

x

A named list, names must match the parameter names of the SQL function, values are the values to set the parameters to when executing the SQL function.

schema

A string, the schema name of the SQL function.

func

A string, the name of the SQL function.

quote_text

TRUE/FALSE, if TRUE, calls quoteText() to add single quotes around character strings.

cast

TRUE/FALSE, if TRUE, will add SQL to cast the parameters to the specified type.

types

A vector of character strings specifying the SQL data types of the function parameters, the position of the type should match the position of the parameter for that type in x.

con

A database connection that can be passed to DBI::dbSendQuery/DBI::dbGetQuery.

Value

A string, PostgreSQL statement to execute a function; or the results retrieved by DBI::dbGetQuery after executing the statement.

Examples

callFUNCTION(
x = list(a = 1, b = 2),
schema = NULL,
func = "sample_add",
quote_text = TRUE,
cast = FALSE,
types = c("INT", "INT")
)

[Package pgTools version 1.0.2 Index]