update_values {sqlHelpers}R Documentation

Generate a UPDATE statement, optionally execute the statement if con is not NULL.

Description

Generate a UPDATE statement, optionally execute the statement if con is not NULL.

Usage

update_values(
  x,
  schema = NULL,
  table,
  where = NULL,
  returning = NULL,
  quote_text = TRUE,
  cast = TRUE,
  types = NULL,
  con = NULL,
  dialect = "T-SQL"
)

Arguments

x

A list, data.frame or data.table, names must match the column names of the destination SQL table.

schema

A string, the schema name of the destination SQL table.

table

A string, the table name of the destination SQL table.

where

A string, conditions to add to a WHERE statement.

returning

A vector of character strings specifying the SQL column names to be returned by the UPDATE statement.

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 data to be inserted to the specified type.

types

A vector of types to use for casting columns. If blank, will look at meta data about table to decide types.

con

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

dialect

A string, "T-SQL" or "Postgresql".

Value

A string, the UPDATE statement; or the results retrieved by DBI::dbGetQuery after executing the statement.

Examples

update_values(
x = list(col1 = c("a"), col2 = c(1)),
schema = "test",
table = "table1",
where = "1=1",
types = c("VARCHAR(12)", "INT")
)

[Package sqlHelpers version 0.1.2 Index]