0% found this document useful (0 votes)
67 views2 pages

Fix Script

This document defines two cursors (c1 and c2) that query different tables to retrieve tax journal entry records where debit and credit amounts are not equal. It then uses these cursors in FOR loops to delete matching records from the jai_tax_journal_entries and gl_interface tables respectively. After the loops, it commits the transaction.

Uploaded by

Anurag Bhaskar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
67 views2 pages

Fix Script

This document defines two cursors (c1 and c2) that query different tables to retrieve tax journal entry records where debit and credit amounts are not equal. It then uses these cursors in FOR loops to delete matching records from the jai_tax_journal_entries and gl_interface tables respectively. After the loops, it commits the transaction.

Uploaded by

Anurag Bhaskar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

DECLARE

CURSOR c1
IS
SELECT (SELECT DISTINCT inv.invoice_num
FROM ap_invoices_all inv,
jai_tax_det_factors det
WHERE inv.invoice_id = det.trx_id
AND jagl.tax_det_factor_id = det.det_factor_id)
inv_number,
jagl.*
FROM jai_tax_journal_entries jagl
WHERE (tax_det_factor_id, tax_line_id) IN (
SELECT det_factor_id, tax_line_id
FROM (SELECT SUM (NVL (entered_dr, 0)) enter_dr,
SUM (NVL (entered_cr, 0)) enter_cr,
reference23 det_factor_id,
reference24 tax_line_id, currency_code
FROM gl_interface
WHERE 1 = 1
-- AND currency_code <> 'INR'
-- AND status = 'EU02,EP01'
AND reference23 IS NOT NULL
AND reference24 IS NOT NULL
AND user_je_source_name = 'Financials India'
AND user_je_category_name = 'AP Validate'
GROUP BY reference23, reference24, currency_code)
WHERE enter_dr <> enter_cr);

CURSOR c2
IS
SELECT *
FROM (SELECT SUM (NVL (entered_dr, 0)) enter_dr,
SUM (NVL (entered_cr, 0)) enter_cr,
reference23 det_factor_id, reference24 tax_line_id,
currency_code
FROM gl_interface
WHERE 1 = 1
-- AND currency_code <> 'INR'
-- AND status = 'EU02,EP01'
AND reference23 IS NOT NULL
AND reference24 IS NOT NULL
AND user_je_source_name = 'Financials India'
AND user_je_category_name = 'AP Validate'
GROUP BY reference23, reference24, currency_code)
WHERE enter_dr <> enter_cr;
BEGIN
FOR i IN c1
LOOP
DELETE jai_tax_journal_entries jagl
WHERE journal_entry_id = i.journal_entry_id;
END LOOP;

FOR j IN c2
LOOP
DELETE gl_interface
WHERE reference23 = j.det_factor_id
AND reference24 = j.tax_line_id
AND user_je_source_name = 'Financials India'
AND user_je_category_name = 'AP Validate';
END LOOP;
END;

COMMIT ;

You might also like