Skip to content

Instantly share code, notes, and snippets.

@manuelgeek
Created August 17, 2017 09:33
Show Gist options
  • Save manuelgeek/8aaf47a9af8ce2013ffe1d86c7674339 to your computer and use it in GitHub Desktop.
Save manuelgeek/8aaf47a9af8ce2013ffe1d86c7674339 to your computer and use it in GitHub Desktop.
MERGE INTO f_on_time_perfomance b
USING (
SELECT RECORDID,to_char(flightdatetime,'YYYYMMDD') as end_date,to_char(numgmtdate,'YYYYMMDD') as start_date,CTFLIGHTNUMBER,ORIGIN,DESTINATION,STDUDT,OUTUDT,STAUDT,INUDT
FROM FSDAILY@MCREPORTS
) e
ON (b.on_time_perfomance_key = e.recordid )
WHEN MATCHED THEN
UPDATE SET b.date_key = e.end_date,b.dept_date = e.start_date,b.flight_no = e.ctflightnumber, b.flight_origin = e.origin, b.flight_destination = e.destination, b.std =e.stdudt,b.atd=e.outudt,
b.sta = e.staudt, b.ata= e.inudt
WHEN NOT MATCHED THEN
INSERT (b.ON_TIME_PERFOMANCE_KEY,b.DATE_KEY,b.FLIGHT_NO,b.FLIGHT_ORIGIN,b.FLIGHT_DESTINATION,b.STD,b.ATD,b.STA,b.ATA, b.ID, b.DEPT_DATE)
VALUES (e.RECORDID,e.end_date,e.CTFLIGHTNUMBER,e.ORIGIN,e.DESTINATION,e.STDUDT,e.OUTUDT,e.STAUDT,e.INUDT, id_key.nextval, e.start_date);
commit;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment