Skip to contents

Look up a list of variables based on a particular variable and its associated values in the database

Usage

lookup_table_sql(
  conn,
  db_table_name,
  return_var = "*",
  exclude_return_var = NULL,
  filter_coln_var = NULL,
  filter_coln_val = NULL,
  filter_var_by = NULL,
  check_db_table = TRUE,
  partial_match_columns = base::character()
)

Arguments

conn

An established database connection

db_table_name

A table in the database

return_var

a list of column variables to be returned from the given table. Default '*' (means everything).

exclude_return_var

a list of column names to be excluded from the returned table.

filter_coln_var

a list of column variables in the given table. Default NULL.

filter_coln_val

a list of values associated with 'filter_coln_var' variables. Most importantly, 'filter_coln_val' must have names or labels that matched the values of 'filter_coln_var'. Default NULL.

filter_var_by

if length(filter_coln_var) > 1, then 'filter_var_by' must be provided as a vector of logical operators (e.g., OR/AND) with n = length(filter_coln_var) - 1. Default NULL.

check_db_table

Check whether table exists in the database. Default = TRUE.