Add Enumerated Type Value
add_enum_value.Rd
add_enum_value()
appends a value to an existing enum
Usage
add_enum_value(
con,
enum = c("bin_code_enum", "survey_type_enum", "life_stage_enum", "origin_enum",
"run_mode_enum", "optics_enum", "light_source_enum", "lamp_energy_enum",
"well_location_enum"),
enum_value
)
Arguments
- con
A DBI connection object obtained from DBI::dbConnect()
- enum
Provide one of the following:
"bin_code_enum" Used for generating sampling protocols and sample IDs
"survey_type_enum" Used for describing the survey types in permits
"life_stage_enum" Used for specifying chinook life stage in permits
"origin_enum" Used for specifying the chinook origin in permits
"run_mode_enum" Used for describing the run mode in the Synergy H1 protocol
"optics_enum" Used for describing the optics setting in the Synergy H1 protocol
"light_source_enum" Used for describing the light source in the Synergy H1 protocol
"lamp_energy_enum" Used for describing the lamp energy setting in the Synergy H1 protocol
"well_location_enum" Used for mapping the Synergy H1 result output to sample IDs well location in the assay results
- enum_value
new value to be added to existing enum
Details
Enumerated (enum) types are data types that comprise a static, ordered set of values. They are useful for controlling the acceptable values within a column of a database when a lookup table is overkill.
See also
Other enum method functions:
get_enum_values()
,
update_enum_value()
Examples
# example database connection
cfg <- config::get()
con <- DBI::dbConnect(RPostgres::Postgres(),
dbname = cfg$dbname,
host = cfg$host,
port = cfg$port,
user = cfg$username,
password = cfg$password)
#> Error: connection to server at "localhost" (::1), port 5432 failed: Connection refused (0x0000274D/10061)
#> Is the server running on that host and accepting TCP/IP connections?
#> connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused (0x0000274D/10061)
#> Is the server running on that host and accepting TCP/IP connections?
# first confirm the new value is not redundant to existing values
get_enum_values(con, "lamp_energy_enum")
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'dbObj' in selecting a method for function 'dbIsValid': object 'con' not found
add_enum_value(con, "lamp_energy_enum", "Low")
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'dbObj' in selecting a method for function 'dbIsValid': object 'con' not found