title: How do i fix the warning message "Closing open result set, cancelling previous query" when querying a PostgreSQL database in R?
body: <p>Below is a snippet of my code that I use in R to extract IDs from a PostgreSQL database. When I run the function I get the following warning message from R:</p>
  
  <blockquote>
    <p>In result_create(conn@ptr, statement) :
    Closing open result set, cancelling previous query</p>
  </blockquote>
  
  <p>How do I avoid this warning message from happening without making use of <code>options(warn=-1)</code> at the beginning of my code, suppressing the warning instead of  </p>
  
  <pre><code>con &lt;- dbConnect(RPostgres::Postgres(),
                   user = "postgres",
                   dbname  = "DataBaseName",
                   password  = "123456",
                   port  = 5431)
  
  
  get_id &lt;- function(connection, table){
  
    query &lt;- toString(paste("SELECT id FROM ", table, sep = ""))
    data_extract_query &lt;- dbSendQuery(connection, query)
    data_extract &lt;- dbFetch(data_extract_query)
    return(data_extract)
  }
  
  
  get_id(con, "users") 
  
  </code></pre>