title: Gettin error ORA-01732: data manipulation operation not legal on this view
body: <p>Hi Gurus I am getting the error ORA-01732: data manipulation operation not legal on this view</p>
  
  <p>when executing the below query</p>
  
  <pre><code>UPDATE (SELECT CR.AMOUNT AS AMOUNT,
                    CASE
                    WHEN MRG.AMOUNT_USD=0
                    THEN CR.AMOUNT
                    ELSE MRG.AMOUNT_USD
                    END AS AMOUNT_BILAT,
                    CR.ISUPDATED
                    FROM CRS_TT_BILAT_EXCL_MERGE1 MRG,CRS_T_CURRENT_RATES1 CR
                    WHERE SUBSTR(CR.DNIS_CD,1,3)=MRG.DNIS_CD
                    AND CR.PRODUCT_CUST_ID = MRG.PRODUCT_CUST_ID
                    AND CR.ISUPDATED &lt;&gt; 'Y'
                    AND ROWNUM = 1)
                    SET AMOUNT = AMOUNT_BILAT;
                    CR.ISUPDATED = 'Y';
  </code></pre>
  
  <p>I have simplified the above code from the below query</p>
  
  <pre><code>UPDATE CRS_T_CURRENT_RATES1 CR
          SET CR.AMOUNT =
            (SELECT 
                    CASE
                    WHEN MRG.AMOUNT_USD=0
                    THEN CR.AMOUNT
                    ELSE MRG.AMOUNT_USD
                    END
                    FROM CRS_TT_BILAT_EXCL_MERGE1 MRG
                    WHERE SUBSTR(CR.DNIS_CD,1,3)=MRG.DNIS_CD
                    AND CR.PRODUCT_CUST_ID = MRG.PRODUCT_CUST_ID
                    AND ROWNUM = 1),
  
                    CR.ISUPDATED = 'Y'
  
             WHERE EXISTS
              (SELECT 1 FROM CRS_TT_BILAT_EXCL_MERGE1 MRG WHERE MRG.DNIS_CD = SUBSTR(CR.DNIS_CD, 1,3) AND CR.PRODUCT_CUST_ID = MRG.PRODUCT_CUST_ID )
              AND
              CR.ISUPDATED &lt;&gt; 'Y';
  </code></pre>
  
  <p>I was trying to optimize the 2nd query, since the second query uses two selects i was trying to replace that with a single query. Can any one please help me on this?</p>