title: PostgreSQL 9.5 - decode / select case to solve error with utf8 doesn't work
body: <p>In continuation of my <a href="https://stackoverflow.com/questions/45280175/migration-oracle-to-postgresql-invalid-byte-sequence-for-encoding-utf8-0x00/45280315?noredirect=1#comment77531407_45280315">last post</a> - &quot;migration oracle to postgresql invalid byte sequence for encoding “UTF8”: 0x00&quot;</p>
  <p>I'm trying to insert into a local PostgreSQL table data from remote Oracle table (via oracle_fdw extension). My Oracle table has a column named street and it has valid string values and sometimes the next  invalid (in PostgreSQL) string : ' ' (space).</p>
  <p>When I try to copy the column value I get the error I mentioned above and in my last post. I understood that I need to change the oracle data before I insert it to PostgreSQL. I must do it on the fly so I tried to search for oracle decode func in PostgreSQL. I found two solution and I used both of them but I got same error:</p>
  <p>1.using select with case :</p>
  <pre><code>mydb=&gt;select *,(case when v.street=' ' then null END) from customer_prod v;
  ERROR:  invalid byte sequence for encoding &quot;UTF8&quot;: 0x00
  CONTEXT:  converting column &quot;street&quot; for foreign table scan of 
   &quot;customer_prod&quot;, row 254148
  </code></pre>
  <hr />
  <p>2.using decode function from orafce extension :</p>
  <pre><code>mydb=&gt;select decode(street,' ',null) from customer_prod;
  ERROR:  invalid byte sequence for encoding &quot;UTF8&quot;: 0x00
  </code></pre>
  <p>So, I'm still getting the error. How can I solve this issue?</p>