mdb-queries is a utility program distributed with MDB Tools. Without query, it lists the names of all saved queries in the database. With query, it returns the SQL text of the named query or queries.

mdb_queries(
  path,
  query = NULL,
  list = TRUE,
  newline = FALSE,
  delimiter = " ",
  as_text = FALSE,
  as_list = TRUE
)

Arguments

path

Path to .mdb/.accdb file.

query

Character vector of query names. When NULL (the default), the function lists available query names instead of fetching SQL.

list

Logical; when TRUE (the default) and query is NULL, return the list of query names. Set to FALSE to suppress listing and return character(0).

newline

Logical; when TRUE and as_text = TRUE, collapse names with "\n" instead of delimiter.

delimiter

Character scalar used to collapse query names when as_text = TRUE. Default " ".

as_text

Logical; when TRUE, collapses the query name list into a single string using delimiter (or "\n" if newline = TRUE).

as_list

Logical; defaults to TRUE. When TRUE and query is supplied, wraps the result in a named mdblist object.

Value

When query is NULL: a character vector of query names (or a collapsed string when as_text = TRUE). When query is supplied and as_list = TRUE: a named mdblist of SQL text strings, one per query. With a single query and as_list = FALSE: a character scalar.

Examples

db <- mdbr:::.mdb_example_nwind_path()
if (nzchar(db)) {
  mdb_queries(db)
  mdb_queries(db, "Orders Qry")
}