title: How to understand netezza modified query?
body: <p>I have the following query extracted from a netezza view, Since there is no record of original query saved. How to understand what this query is doing?</p>
  
  <pre><code>CASE 
      WHEN (O.E_SRC ~~LIKE_ESCAPE('FIX.%.OrderNew'::"VARCHAR", '\'::"VARCHAR"))
      THEN ADMIN."REPLACE"(ADMIN."REPLACE"(O.E_SRC, '.OrderNew'::"VARCHAR", ''::"VARCHAR"),
                          'FIX.'::"VARCHAR", ''::"VARCHAR")
      ELSE O.E_SRC
  END AS CONNECTION_ID
  </code></pre>
  
  <p>What I understood is, there is a pattern matching on <code>FIX.%.OrderNew</code> and it does some kind of replace. So what would be the original query saves?
  Like <code>NVL(RNO,0)</code> is saved as  </p>
  
  <pre><code>CASE 
      WHEN (RNO NOTNULL) THEN RNO
      WHEN (0 NOTNULL) THEN 0
      ELSE NULL::INT4
  END
  </code></pre>
  
  <p>So what is the original query equivalent to <code>nvl()</code> or some other function of the following netezza modified query</p>
  
  <pre><code>CASE 
      WHEN (O.E_SRC ~~LIKE_ESCAPE('FIX.%.OrderNew'::"VARCHAR", '\'::"VARCHAR"))
      THEN ADMIN."REPLACE"(ADMIN."REPLACE"(O.E_SRC, '.OrderNew'::"VARCHAR", ''::"VARCHAR"),
                           'FIX.'::"VARCHAR", ''::"VARCHAR")
      ELSE O.E_SRC
  END AS CONNECTION_ID
  </code></pre>