hsFields: Available Fields in Database Table

View source: R/hsFields.R

hsFieldsR Documentation

Available Fields in Database Table

Description

Returns a vector containing the field names of a database table.

Usage

hsFields(
  mdb,
  tbl,
  namesOnly = TRUE,
  chopDollar = TRUE,
  ignore.case = (!isMySQL(mdb, use2007Driver = use2007Driver)),
  use2007Driver = NULL,
  dbg = FALSE
)

Arguments

mdb

full path to MS Access database file (extension “.mdb” or “.accdb”) or MS Excel file (extension “.xls” or “.xlsx”).

tbl

table name.

namesOnly

if TRUE, only field names are returned, otherwise all available information on the fields. Default: TRUE

chopDollar

if TRUE (default), a dollar sign at the end of the table name is removed before sending it to sqlColumns,

ignore.case

if TRUE, case is ignored when comparing the given table with the names of the existing tables. Default: FALSE

use2007Driver

passed to isMySQL

dbg

if TRUE, debug messages are shown

Value

Vector containing the field names of the database table (if namesOnly = TRUE) or data.frame with columns COLUMN_NAME, DATA_TYPE, TYPE_NAME, COLUMN_SIZE, BUFFER_LENGTH, DECIMAL_DIGITS, NUM_PREC_RADIX, NULLABLE describing the database fields in detail, otherwise.

See Also

hsTables

Examples

## Not run:  
## List the fields of table "tbl_Hyd" in the example database
## (only on Windows!)

if (.Platform$OS.type == "windows") {
  setCurrentSqlDialect("msaccess")
  fields <- hsFields(xmdb(), "tbl_Hyd")
  fields
}
  
## Ouput:
# [1] "Zeitst"  "Q"       "v"       "H"       "T_Kanal"

## End(Not run)


KWB-R/kwb.db documentation built on Oct. 1, 2023, 4:10 a.m.