title: PostgreSQL Squence Not Working When Updating Column Details
body: <p>I have created a function to update a column in a postgresSQL table using Sequence nextval() function.Function body is as follows</p>
  
  <pre><code>BEGIN
      EXECUTE 'CREATE SEQUENCE '|| sequence_name || ' START 1';
      EXECUTE 'UPDATE ' ||selected_table_name|| ' SET record_id = '||nextval(sequence_name);
      RETURN 'SUCCESS';
  END;
  </code></pre>
  
  <p>But when I call function as follows</p>
  
  <pre><code>SELECT staging.update_record_id('staging.test_table','staging.sq_test_table');
  </code></pre>
  
  <p>Its  update my relevant column with 1 for all the records.But when I just use the following command in the console directly it update the all the values with increments.The console code as follows.</p>
  
  <pre><code>update staging.test_table set record_id = nextval('staging.sq_test_table');
  </code></pre>
  
  <p>Is anyone can give a solution for this, would be much grateful</p>