Review
Geraldo Peralta, February 19, 2019 - 2:05 pm UTC
Thanks for the response.
update table1
set processed = ...
where t1.primary_key IN (
select table1.primary_key
from table1 t1
LEFT JOIN table2 t2
ON t1.ID = t2.ID
INNER JOIN table3 t3
ON (t3.invoice_sender = t1.invoice_sender AND t3.einvoice = t1.einvoice)
AND t1.LOADED_606 = 0 --look for the rows not loaded (flagged as 0) in my ETL package
AND t3.APPROVALS = 0 --lok for accepted approvals
AND t3.INV_SENT_DATE < TRUNC(SYSDATE)+1 AND t3.INV_SENT_DATE >=
(CASE
WHEN TO_NUMBER(TO_CHAR(SYSDATE,'DD')) <= 15
THEN TRUNC(SYSDATE-20,'MM')
ELSE TRUNC(SYSDATE,'MM')
END)
AND (t1.invoice_type NOT IN (32,41,43) OR substr(t2.modified_einvoice,2,2) not in (02,32));
)
I changed = symbol to IN because could be more than one row to process.
The sub-query, that is used to transport the data, returns 3 rows, the update affects 3 rows.
I set the flagged ones to null once processed to boost performance (recommended by you).
Anything else to have in mind?
Thanks in advanced.
February 20, 2019 - 3:32 am UTC
Looks good
Review
Geraldo Peralta, February 28, 2019 - 11:26 pm UTC
Thanks for the help.