Skip to contents

Fetch table contents by primary keys Function to query contents of a database table with a vector of primary key values. Useful for double-checking before running 'modify_rows' or 'delete_rows'. It could be useful for querying information across tables.

Usage

query_table_by_pk(
  table_name = NULL,
  pkvec = NULL,
  pkfield = "uid",
  public = getOption("drivesR.default.public"),
  public_tables = getOption("drivesR.default.tablevec")
)

Arguments

table_name

The table identifier in the DRIVES database. If public = TRUE, the table name is automatically modified to query the public version of the database table.

pkvec

A vector of primary key values.

pkfield

The name of the column name that holds the table's primary key. For most tables, this is 'uid'.

public

If TRUE, the function queries publicly available data tables. Since this function is mostly for internal use, the default is FALSE.

public_tables

Vector of tables that receive the public_ prefix if public==TRUE. Set as a global default.

Value

A dataframe of the specified tables subsetted for rows matching the primary key vector.

Examples

#not run: qtable <- query_table_by_pk("harvest_dates",pkvec = 1:100, pkfield = "uid)