This content has been marked as final. Show 3 replies
Oh what the heck, I'll take a crack at it. Rewriting it, that is. I'm assuming your original statement is logically correct.
I don't have your tables and data so I have no idea how this will perform but at least it doesn't update every row in your table. (your original update has no WHERE clause)
merge into q_ventas_ora@artus imp using (select v.customer_trx_id ,v.link_to_cust_trx_line_id ,min(case when t.tax_code like '%IEPS%' then nvl(v.tax_rate,0)/100 else null end) ieps_rate ,min(case when t.tax_code like '%IVA%' then nvl(v.tax_rate,0)/100 else null end) iva_rate from ra_customer_trx_lines_all v ,ar_vat_tax_all t where t.vat_tax_id = v.vat_tax_id and v.line_type = 'TAX' and (t.tax_code like '%IEPS%' or t.tax_code like '%IVA%' ) group by v.customer_trx_id ,v.link_to_cust_trx_line_id ) u on ( u.customer_trx_id = imp.customer_trx_id and u.link_to_cust_trx_line_id = imp.customer_trx_line_id ) when matched then update set imp.ieps = u.ieps_rate * imp.precio ,imp.iva = u.iva_rate * ((imp.precio * u.ieps_rate) + imp.precio) ;
What version ???
With 11gR2 ( > 188.8.131.52), you can use DBMS_PARALLEL_EXECUTE procedure. If you truely need to update every row in the table, this procedure can help by breaking the table into tiny pieces and operating on it in parallel.
Search the docs for this procedure and an example of how to code the procedure.