title: Update multiple values from an array with array_replace()
body: <p>I am trying to do an update of a table in PostgreSQL.</p>
  
  <p>In fact, I am trying to update an array. I have an table call switch_ids of OLD_ID, NEW_ID and I have the table TABLE_TO_UPDATE with a column my_array (an array of ids). I want to modify some of the ids in this array. I do something like that:</p>
  
  <pre><code>UPDATE TABLE_TO_UPDATE
  SET my_array=array_replace(my_array,OLD_ID,NEW_ID)
  FROM switch_ids
  WHERE switch_ids.old_id = ANY(my_array);
  </code></pre>
  
  <p>The problem is that when there are multiple values to change in the same row (in my_array), it only changes one value and not all. How can I update them all at the same time? Nested calls?</p>