Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

dbFetch-DatabaseConnectorResult-method

Fetch records from a previously executed query


Description

Fetch the next n elements (rows) from the result set and return them as a data.frame.

Usage

## S4 method for signature 'DatabaseConnectorResult'
dbFetch(res, datesAsString = FALSE, ...)

Arguments

res

An object inheriting from DBIResult, created by dbSendQuery().

datesAsString

Should dates be represented as strings? (instead of Date objects)

...

Other arguments passed on to methods.

Details

fetch() is provided for compatibility with older DBI clients - for all new code you are strongly encouraged to use dbFetch(). The default implementation for dbFetch() calls fetch() so that it is compatible with existing code. Modern backends should implement for dbFetch() only.

Value

dbFetch() always returns a data.frame with as many rows as records were fetched and as many columns as fields in the result set, even if the result is a single value or has one or zero rows. An attempt to fetch from a closed result set raises an error. If the n argument is not an atomic whole number greater or equal to -1 or Inf, an error is raised, but a subsequent call to dbFetch() with proper n argument succeeds. Calling dbFetch() on a result set from a data manipulation query created by dbSendStatement() can be fetched and return an empty data frame, with a warning.

See Also

Close the result set with dbClearResult() as soon as you finish retrieving the records you want.


DatabaseConnector

Connecting to Various Database Platforms

v4.0.2
Apache License
Authors
Martijn Schuemie [aut, cre], Marc Suchard [aut], Observational Health Data Science and Informatics [cph], Microsoft Inc. [cph] (SQL Server JDBC driver), PostgreSQL Global Development Group [cph] (PostgreSQL JDBC driver), Oracle Inc. [cph] (Oracle JDBC driver), Amazon Inc. [cph] (RedShift JDBC driver)
Initial release
2021-04-12

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.