title: Issue with using nested case conditions in Oracle SQL query
body: <p>i have a scenario where in , i need to calculate an employeee salary using a package , which gives me salary remaining for permanent employee if there is some prepayment and then convert the calculated value to a currency specified by the employee using another package.</p>
  
  <p>How i have been doing this is:</p>
  
  <pre><code>CASE
    WHEN ( ai.employee_type = 'PERMANENT' and ai.payment_status_flag='Y')
    THEN EMP_UTILS_PKG.get_pay_amount_remaining( ai.employee_id )
    ELSE ail.amount_remaining
  END amount_remaining,
  CASE
    WHEN ( ai.salary_currency_code = NVL(find_currency('EMP_COMMON_CURRENCY'),ai.EMP_CURRENCY_CODE))
    THEN CASE
               WHEN ( ai.employee_type = 'PERMANENT' and ai.payment_status_flag='Y')
                  THEN EMP_UTILS_PKG.get_pay_amount_remaining( ai.employee_id )
               ELSE ail.amount_remaining
    END
    ELSE EMP_API.convert_closest_amount_sql( x_from_currency =&gt; ai.EMP_CURRENCY_CODE ,x_to_currency =&gt; find_currency('EMP_COMMON_CURRENCY') ,x_amount =&gt;( CASE
               WHEN ( ai.employee_type = 'PERMANENT' and ai.payment_status_flag='Y')
                  THEN EMP_UTILS_PKG.get_pay_amount_remaining( ai.employee_id )
               ELSE ail.amount_remaining
  END) ,x_max_roll_days =&gt; -1)
  END EMP_CONVERTED_AMOUNT_REMAINING, 
  </code></pre>
  
  <p>I have repeated below condition 3 times in my query:</p>
  
  <pre><code>WHEN ( ai.employee_type = 'PERMANENT' and ai.payment_status_flag='Y')
     THEN EMP_UTILS_PKG.get_pay_amount_remaining( ai.employee_id )
     ELSE ail.amount_remaining
  </code></pre>
  
  <p>Is there a simpler approach for this, can we avoid repeating code like this?</p>