\Header{fetch-methods}{Fetch records from a previously executed query}
\alias{fetch,SQLiteResult,numeric-method}{fetch-methods}
\alias{fetch,SQLiteResult-method}{fetch-methods}
\keyword{interface}{fetch-methods}
\keyword{interface}{fetch-methods}
\keyword{database}{fetch-methods}
\begin{Description}\relax
This method is a straight-forward implementation of the corresponding
generic function.\end{Description}
\begin{Details}\relax
The \code{RSQLite} implementations retrieves all records into a 
buffer internally managed by the RSQLite driver (thus this memory
in not managed by R but its part of the R process), and
\code{fetch} simple returns records from this internal buffer.\end{Details}
\begin{Section}{Methods}
\describe{

\item[res] an \code{SQLiteResult} object.

\item[n] maximum number of records to retrieve per fetch.
Use \code{n = -1} to retrieve all pending records;
use a value of \code{n = 0} for fetching the default number 
of rows \code{fetch.default.rec} defined in the 
\code{\Link{SQLite}} initialization invocation.

\item[\dots ] currently not used.
}\end{Section}
\begin{References}\relax
See the Database Interface definition document
\code{DBI.pdf} in the base directory of this package
or \url{http://developer.r-project.org/db}.\end{References}
\begin{SeeAlso}\relax
\code{\Link{SQLite}},
\code{\Link{dbConnect}},
\code{\Link{dbSendQuery}},
\code{\Link{dbGetQuery}},
\code{\Link{dbClearResult}},
\code{\Link{dbCommit}},
\code{\Link{dbGetInfo}},
\code{\Link{dbReadTable}}.\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
drv <- dbDriver("SQLite")
con <- dbConnect(drv, dbname = "sqlite.db")
res <- dbSendQuery(con, statement = paste(
                      "SELECT w.laser_id, w.wavelength, p.cut_off",
                      "FROM WL w, PURGE P", 
                      "WHERE w.laser_id = p.laser_id",
                      "ORDER BY w.laser_id"))
# we now fetch the first 100 records from the resultSet into a data.frame
data1 <- fetch(res, n = 100)   
dim(data1)

dbHasCompleted(res)

# let's get all remaining records
data2 <- fetch(res, n = -1)

\end{ExampleCode}
\end{Examples}

