title: How to insert all the records in a data frame into the database in R?
body: <p>I have a data frame <code>data_frm</code> which has following columns:</p>
  
  <pre><code>emp_id | emp_sal | emp_bonus | emp_desig_level
         |         |           |    
         |         |           |
  </code></pre>
  
  <p>And I want to insert all the records present in this data frame into the database table <code>tab1</code>.I executed this query but I got an error:</p>
  
  <pre><code>for(record in data_frm)
      {   
      write_sql &lt;- paste("Insert into tab1 (emp_id,emp_sal,emp_bonus,emp_desig_level) values (",data_frm[,"emp_id"],",",data_frm[,"emp_sal"],",",data_frm[,"emp_bonus"],",",data_frm[,"emp_desig_level"],")",sep="") 
      r &lt;- dbSendQuery(r,write_sql)   
      }
  </code></pre>
  
  <p>I get error as:</p>
  
  <pre><code>Error in data_frm[, "emp_id"] : incorrect number of dimensions
  </code></pre>
  
  <p>How do I insert all the records from the data frame into database?</p>
  
  <p><strong>NOTE:</strong> I want to insert all the records of the data frame using <code>insert</code> statement.</p>