title: Conditionally replace single value per row in jsonb column
body: <p>I need a more efficient way to update rows of a single table in Postgres 9.5.
  I am currently doing it with pg_dump, and re-import with updated values after search and replace operations in a Linux OS environment.  </p>
  
  <p><code>table_a</code> has 300000 rows with 2 columns: <code>id bigint</code> and <code>json_col jsonb</code>.
  <code>json_col</code> has about 30 keys: "C1" to "C30" like in this example:</p>
  
  <pre><code>Table_A
  
      id,json_col
      1  {"C1":"Paris","C2":"London","C3":"Berlin","C4":"Tokyo", ... "C30":"Dallas"}
      2  {"C1":"Dublin","C2":"Berlin","C3":"Kiev","C4":"Tokyo", ... "C30":"Phoenix"}
      3  {"C1":"Paris","C2":"London","C3":"Berlin","C4":"Ankara", ... "C30":"Madrid"}
      ...
  </code></pre>
  
  <blockquote>
    <p>The requirement is to mass search all keys from C1 to C30 then look in
    them for the value "Berlin" and replace with "Madrid" and only if
    Madrid is not repeated. i.e. id:1 with Key C3, and id:2 with C2. id:3
    will be skipped because C30 exists with this value already</p>
  </blockquote>
  
  <p>It has to be in a single SQL command in PostgreSQL 9.5, one time and considering all keys from the <code>jsonb</code> column.</p>