get_returned_rows | R Documentation |
RETURNING
rowsget_returned_rows()
extracts the RETURNING
rows produced by
rows_insert()
, rows_append()
, rows_update()
, rows_upsert()
,
or rows_delete()
if these are called with the returning
argument.
An error is raised if this information is not available.
has_returned_rows()
checks if x
has stored RETURNING rows produced by
rows_insert()
, rows_append()
, rows_update()
, rows_upsert()
,
or rows_delete()
.
get_returned_rows(x)
has_returned_rows(x)
x |
A lazy tbl. |
For get_returned_rows()
, a tibble.
For has_returned_rows()
, a scalar logical.
library(dplyr)
con <- DBI::dbConnect(RSQLite::SQLite(), ":memory:")
DBI::dbExecute(con, "CREATE TABLE Info (
id INTEGER PRIMARY KEY AUTOINCREMENT,
number INTEGER
)")
info <- tbl(con, "Info")
rows1 <- copy_inline(con, data.frame(number = c(1, 5)))
rows_insert(info, rows1, conflict = "ignore", in_place = TRUE)
info
# If the table has an auto incrementing primary key, you can use
# the returning argument + `get_returned_rows()` its value
rows2 <- copy_inline(con, data.frame(number = c(13, 27)))
info <- rows_insert(
info,
rows2,
conflict = "ignore",
in_place = TRUE,
returning = id
)
info
get_returned_rows(info)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.