dbINSERT: Insert Single Record into an SQL Table

Description Usage Arguments Value Examples

View source: R/SQLquery.R

Description

Insert Single Record into an SQL Table

Usage

1
dbINSERT(con, ..., .table, .verbose = FALSE)

Arguments

con

SQL database connection object

...

named arguments used as pairs (field, value)

.table

name of the table into which the recored is inserted

.verbose

verbose level

Value

the primary key of the newly inserted record

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# connect to sample database
con <- .dbSampleConnection()
dbGetQuery(con, 'SELECT * FROM test')

# insert single record
id <- dbINSERT(con, a = 1, b = 'blabla', c = NA, t = sql_NOW, .table = 'test')
id

# query table again
dbGetQuery(con, 'SELECT * FROM test')

# clean up
dbEMPTY(con, 'test')

renozao/dbutils documentation built on May 27, 2019, 5:53 a.m.