dbReadTable-methods           package:DBI           R Documentation

_C_o_n_v_e_n_i_e_n_c_e _f_u_n_c_t_i_o_n_s _f_o_r _I_m_p_o_r_t_i_n_g/_E_x_p_o_r_t_i_n_g _D_B_M_S _t_a_b_l_e_s

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

     These functions mimic their R/S-Plus counterpart  'get', 'assign',
     'exists',  'remove', and 'objects', except that they generate code
     that gets remotely executed in a database engine.

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

       dbReadTable(conn, name, row.names = "row_names", ...)
       dbWriteTable(conn, name, value, row.names = T, ...,
                   overwrite = F, append = F)
       dbExistsTable(conn, name, ...)
       dbRemoveTable(conn, name, ...)

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

    conn: a database connection object. 

    name: a character string specifying a DBMS table name. 

   value: a data.frame (or coercible to data.frame). 

row.names: in the case of 'dbReadTable', this argument can be a string
          or an index specifying the column in the DBMS table to be
          used as  'row.names' in the output data.frame (a 'NULL',
          '""', or 0  specifies that no column should be used as
          'row.names' in the output).

          In the case of 'dbWriteTable', this argument should be a
          logical specifying whether the 'row.names' should be output
          to the output DBMS table; if 'TRUE', an extra field whose
          name will be  whatever the R/S-Plus identifier '"row.names"'
          maps to the DBMS (see 'make.db.names'). 

overwrite: a logical specifying whether to overwrite an existing table
          or not.  Its default is 'FALSE'. 

  append: a logical specifying whether to append to an existing table
          in the DBMS.  Its default is 'FALSE'. 

    ... : any optional arguments that the underlying database driver
          supports.  

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

     'dbReadTable' returns a data.frame; all other functions return
     'TRUE' or 'FALSE' denoting whether the operation was successful or
     not.

_S_i_d_e _E_f_f_e_c_t_s:

     A DBMS statement is generated and remotely executed on a database
     engine; the result set it produces is fetched in its entirety.
     These operations may failed if the underlying database driver runs
     out of available connections and/or result sets, or the operation
     violates DBMS integrity constraints (e.g., attempting to write
     duplicate values on a field that's defined as a primary key).

     'dbWritetable' slightly extend the semantics of 'assign' to  allow
     overwriting or appending to an existing table.

_N_o_t_e:

     The translation of identifiers between R/S-Plus and SQL is done
     through calls to 'make.names' and 'make.db.names',  but we cannot
     guarantee that the conversion is reversible.  For details see
     'make.db.names'.

_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://developer.r-project.org/db>.

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

     'dbDriver', 'dbConnect', 'dbSendQuery', 'dbGetQuery', 'fetch',
     'dbCommit', 'dbGetInfo', 'dbListTables', 'dbReadTable'.

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

     ## Not run: 
     conn <- dbConnect("MySQL", group = "vitalAnalysis")
     con2 <- dbConnect("Oracle", username = "user", password = "pwd")
     if(dbExistsTable(con2, "fuel_frame")){
        fuel.frame <- dbReadTable(con2, "fuel_frame")
        dbRemoveTable(conn, "fuel_frame")
        dbWriteTable(conn, "fuel_frame", fuel.frame)
     }
     if(dbExistsTable(conn, "RESULTS")){
        dbWriteTable(conn, "RESULTS", results2000, append = T)
     else
        dbWriteTable(conn, "RESULTS", results2000)
     }
     ## End(Not run)

