get_returned_rows {dbplyr} | R Documentation |
Extract and check the RETURNING
rows
Description
get_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()
.
Usage
get_returned_rows(x)
has_returned_rows(x)
Arguments
x |
A lazy tbl. |
Value
For get_returned_rows()
, a tibble.
For has_returned_rows()
, a scalar logical.
Examples
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)
[Package dbplyr version 2.5.0 Index]