title: NVL (EXPR1,0) vs NVL(EXPR1,-1)
body: <pre><code>MERGE INTO A
  USING (  
      SELECT B_1,B_2,B_3,SUM(B_4)
      FROM B
      GROUP BY B_1,B_2,B_3) srt
  ON (
      A.A_1 = B.B_1
      AND NVL (A.A_2, 0) =
              NVL (B.B_2, 0)
      AND NVL (A.A_3, ' ') =
              NVL (B.B_3, ' ') )
  WHEN MATCHED
  THEN   'DML STATEMENT';
  </code></pre>
  
  <p>Above throws an error </p>
  
  <blockquote>
    <p>Caused by: java.sql.SQLException: ORA-06502: PL/SQL: numeric or value
    error: character to number conversion error ORA-30926: unable to get a
    stable set of rows in the source tables</p>
  </blockquote>
  
  <p>But when you replace the above query with below NVL(EXPR, -1) it works without any error. Any reason one can foresee I am unable to see?</p>
  
  <pre><code>MERGE INTO A
  USING (  
      SELECT B_1,B_2,B_3,SUM(B_4)
      FROM B
      GROUP BY B_1,B_2,B_3) srt
  ON (
      A.A_1 = B.B_1
      AND NVL (A.A_2, -1) =
              NVL (B.B_2, -1)
      AND NVL (A.A_3, ' ') =
              NVL (B.B_3, ' ') )
  WHEN MATCHED
  THEN   'DML STATEMENT';
  </code></pre>