odbcTables {RODBC} | R Documentation |
R functions which talk directly to the ODBC interface.
odbcTables(channel, catalog = NULL, schema = NULL, tableName = NULL, tableType = NULL) odbcColumns(channel, table, catalog = NULL, schema = NULL) odbcPrimaryKeys(channel, table, catalog = NULL, schema = NULL) odbcQuery(channel, query, rows_at_time = attr(channel, "rows_at_time")) odbcFetchRows(channel, max = 0, buffsize = 1000, nullstring = NA_character_, believeNRows = TRUE)
channel |
connection handle as returned by
odbcConnect , of class "RODBC" . |
catalog, schema, tableName, tableType |
NULL or character:
whether these do anything depends on the ODBC driver. The first
three can be length-one character vectors, and tableType can
specify zero or more types. |
query |
any valid SQL statement. |
table |
a database table name accessible from the connected DSN. This can be either a character string or an (unquoted) symbol. |
rows_at_time |
The number of rows to fetch at a time, up to 1024. Not
all drivers work correctly with values > 1: see sqlQuery . |
max |
limit on the number of rows to fetch, with 0 indicating no limit. |
buffsize |
the number of records to be transferred at a time. |
nullstring |
character string to be used when reading
SQL_NULL_DATA items in a column transferred as character. |
believeNRows |
logical. Is the number of rows returned by the ODBC connection believable? Not true for Oracle, apparently. |
The first three functions enquire about the tables on the connected
database. Whether the extra arguments do anything and what they do,
depends on the ODBC driver: see the help on sqlTables
for some driver-specific details.
odbcFetchRows
returns a data frame of the pending rowset,
limited to max
rows if max
is greater than 0.
buffsize
may be increased from the default of 1000 rows for
increased performance in a large dataset. This only has an effect with
servers that do not return the number of rows affected by a query
e.g. MS Access, MS SQLServer.
Most return 1
on success and -1
on failure,
indicating that a message is waiting to be retrieved
odbcGetErrMsg
. odbcFetchRows
may return
-2
indicating "No Data"
, the message that would be
returned by odbcGetErrMsg
.
Michael Lapsley and Brian Ripley
sqlQuery
, odbcConnect
,
odbcGetErrMsg
.