Learn R Programming

toaster (version 0.5.5)

isTable: Test if table present in the database.

Description

Tests each element if a table or a view exists in one of database schemas. Names could be just table name of schema followed by table name via '.'. ;

Usage

isTable(channel, tables, withNames = FALSE, allTables = NULL)

Arguments

channel
object as returned by odbcConnect.
tables
list of table names. Name may contain schema name followed by dot and table name or may be NULL. All visible schemas are checked when table specified without a schema. NULL corresponds to not a table.
withNames
logical indicates if table components included in the results.
allTables
a data frame containing table-like objects accessible from Aster. Usually obtained with sqlTables.

Value

logical vector indicating if corresponding name is table in Aster database. Special case when name contains a SQL query triggers NA value instead. This behavior is handy when checking if a table name corresponds to a table (or a view) or a SQL query instead. For example, to test if all names are either existing tables or views or SQL queries use something like this: result = isTable(...); if(all(result | is.na(result)) ...

See Also

getTableSummary

Examples

Run this code
if(interactive()){
# initialize connection to Lahman baseball database in Aster 
conn = odbcDriverConnect(connection="driver={Aster ODBC Driver};
                         server=<dbhost>;port=2406;database=<dbname>;uid=<user>;pwd=<pw>")

isTable(conn, "pitching")        # TRUE 
isTable(conn, "pitch%")          # TRUE
isTable(conn, "public.pitching") # FALSE
}

Run the code above in your browser using DataLab