title: How can i get the unique key violating column name at the time of execution in postgresql
body: <p>I am inserting in multiple tables with foreach loop and I want unique-key column name due to which violating unique key constraints at the run time so i can modify the value and insert it.</p>
  
  <pre><code>foreach ($data as $table_name){
  
   $sql="INSERT INTO $table_name ($column_name) VALUES ($column_vlues)"
  
  $result=query_params($db_conn,$sql,$params)
   if($result){
    //Do nothing. Its fine
  }else{
   //If its voileting the unique key contraints then change the column value like new column value = $column_name_which_voileting.$value and then insert it.
   }
  }
  </code></pre>
  
  <p>Any help will be appriciated.</p>