Learn R Programming

RMySQL (version 0.9-3)

dbNextResult: Fetch next result set from an SQL script or stored procedure (experimental)

Description

Fetches the next result set from the output of a multi-statement SQL script or stored procedure; checkes whether there are additonal result sets to process.

Usage

dbNextResult(con, ...)
dbMoreResults(con, ...)

Arguments

con
a connection object (see dbConnect).
...
any additional arguments to be passed to the dispatched method

Value

  • dbNextResult returns a result set or NULL.

    dbMoreResults returns a logical specifying whether or not there are additional result sets to process in the connection.

Note

Currently only the MySQL driver implements these methods. See 'methods?dbNextMethod'.

Details

SQL scripts (i.e., multiple SQL statements separated by ';') and stored procedures oftentimes generate multiple result sets. These DBI generic functions provide a means to process them sequentially.

dbNextResult fetches the next result from the sequence of pending results sets; dbMoreResults returns a logical to indicate whether there are additional results to process.

See Also

MySQL dbConnect dbSendQuery fetch

Examples

Run this code
rs1 <- dbSendQuery(con, 
         paste(
             "select Agent, ip\_addr, DATA from pseudo\_data order by Agent",
             "select * from Agent\_name",
              sep = ";")
         )
x1 <- fetch(rs1, n = -1)
if(dbMoreResults(con)){
   rs2 <- dbNextResult(con)
   x2 <- fetch(rs2, n = -1)
}

Run the code above in your browser using DataLab