I have 4 remote locations and oracle express database installed. The locations create some transactions there and I want to run a job/procedure once in a day to insert the new records into a central table at our head office. The table structure of the head office and remote table is exactly same.
I am running the below query but it doesn't insert any record. I don't want to use materialized views or drop the head office table every day and create it again.
INSERT INTO CENTRAL_DATA
SELECT *
FROM (SELECT LOCATION_ID,
INVOICE_ID,
INVOICE_DATE,
ANALYSIS_1,
ANALYSIS_2
FROM INVOICEDATA@LOC1
UNION ALL
SELECT LOCATION_ID,
INVOICE_ID,
INVOICE_DATE,
ANALYSIS_1,
ANALYSIS_2
FROM INVOICEDATA@LOC2
UNION ALL
SELECT LOCATION_ID,
INVOICE_ID,
INVOICE_DATE,
ANALYSIS_1,
ANALYSIS_2
FROM INVOICEDATA@LOC3)
WHERE NOT EXISTS (SELECT * FROM CENTRAL_DATA)
Any help will be highly appreciated. Thanks.