fetch-methods             package:RMySQL             R Documentation

_F_e_t_c_h _r_e_c_o_r_d_s _f_r_o_m _a _p_r_e_v_i_o_u_s_l_y _e_x_e_c_u_t_e_d _q_u_e_r_y

_D_e_s_c_r_i_p_t_i_o_n:

     This method is a straight-forward implementation of the
     corresponding generic function.

_D_e_t_a_i_l_s:

     The 'RMySQL' implementations retrieves only 'n' records, and if
     'n' is missing it only returns up to 'fetch.default.rec' as
     specified in the call to 'MySQL' (500 by default).

_M_e_t_h_o_d_s:


     _r_e_s an 'MySQLResult' object.

     _n maximum number of records to retrieve per fetch. Use 'n = -1' to
          retrieve all pending records; use a value of 'n = 0' for
          fetching the default number  of rows 'fetch.default.rec'
          defined in the  'MySQL' initialization invocation.

     ...  currently not used.

_R_e_f_e_r_e_n_c_e_s:

     See the Database Interface definition document 'DBI.pdf' in the
     base directory of this package or <URL:
     http://stat.bell-labs.com/RS-DBI>.

_S_e_e _A_l_s_o:

     'MySQL', 'dbConnect', 'dbSendQuery', 'dbGetQuery',
     'dbClearResult', 'dbCommit', 'dbGetInfo', 'dbReadTable'.

_E_x_a_m_p_l_e_s:

     ## Not run: 
     drv <- dbDriver("MySQL")
     con <- dbConnect(drv, user = "opto", password="pure-light", 
                      host = "localhost", dbname="lasers")
     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(Not run)

