sqlFetch                package:RODBC                R Documentation

_R_e_a_d_i_n_g _T_a_b_l_e_s _f_r_o_m _O_D_B_C _D_a_t_a_b_a_s_e_s

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

     Read a table of an ODBC database into a data frame.

_U_s_a_g_e:

     sqlFetch(channel, sqtable, ..., colnames = FALSE, rownames = TRUE)

_A_r_g_u_m_e_n_t_s:

 channel: connection handle returned by `odbcConnect'.

 sqtable: a database table name accessible from the connected dsn. This
          should be either a character string or a character vector of
          length 1.

     ...: additional arguments to be passed to `sqlGetResults'.

colnames: logical: retrieve column names from first row of table?

rownames: either logical or character. If logical, retrieve row names
          from the first column (`rownames') in the table?  If
          character, the column name to retrieve them.

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

     `sqlFetch' retrieves the the entire contents of the table
     `sqtable'.  Rownames and column names are restored as indicated.

     It tries to cope with the peculiar way the Excel ODBC driver
     handles table names.

     Useful additional parameters to pass to `sqlGetResults' include

     `_m_a_x': limit on the number of rows to fetch, with 0 (the default)
          indicating no limit. \item`{nullstring}:'{character string to
          be used when reading `SQL_NULL_DATA' character items from the
          database.}

     `_n_a._s_t_r_i_n_g_s': character string(s) to be mapped to `NA' when
          reading character data.

     `_a_s._i_s': as in `sqlGetResults'.

     `_d_e_c': The character for the decimal place to be assumed when
          converting character columns.

_V_a_l_u_e:

     A data frame on success, or a character or numeric error code (see
     `sqlQuery').

_A_u_t_h_o_r(_s):

     Michael Lapsley and Brian Ripley

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

     `sqlSave', `sqlQuery', `odbcConnect', `odbcGetInfo'

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

     library(RODBC)
     data(USArrests)
     channel <- odbcConnect("test", "", "") # userId and password
     sqlSave(channel, USArrests, verbose = TRUE)
     sqlFetch(channel, "USArrests") # get the lot
     sqlDrop(channel, "USArrests") 
     odbcClose(channel)

