You are on page 1of 2

SELECT * FROM LRO_COUNTRY_REF WHERE iso_country_cd=;

MERGE INTO LRO_XGC_COUNTRY_STG a


USING (select DISTINCT iso_country_cd,
creation_usr,
last_update_usr
from lro_all_country_stg
) b
ON(a.iso_country_cd = b.iso_country_cd)
WHEN MATCHED THEN UPDATE
SET
a.creation_usr = b.creation_usr,
a.last_update_usr = b.last_update_usr
WHEN NOT MATCHED THEN
INSERT (
a.COUNTRY_REF_ID,
a.ISO_COUNTRY_CD,
a.CREATION_TS,
a.LAST_UPDATE_TS,
a.CREATION_USR,
a.LAST_UPDATE_USR,
a.SUPPORTED_IND
)
VALUES(
LROCTLARF_COUNTRYREFID_SEQ.nextval,
b.ISO_COUNTRY_CD,
systimestamp,
systimestamp,
b.CREATION_USR,
b.LAST_UPDATE_USR,
'N'
);

/* INSERT NEW ISO COUNTRY DATA INTO STAGING TABLE FROM CURENT XGC DATABASE */
INSERT INTO LRO_XGC_COUNTRY_STG (
iso_country_cd,
lang_cd,
country_nam,
is_exonym_ind,
is_tran_ind,
is_default_lang_ind,
creation_ts,
last_update_ts,
creation_usr,
last_update_usr,
map_version_nam
)
SELECT DISTINCT b.iso_country_code,
b.lan_code,
b.name,
b.is_exonym,
b.is_trans,
decode(a.default_language, b.lan_code, 'Y', 'N') as is_default_lang_
ind,
systimestamp,
systimestamp,
'&xgc_usr_short_name',
'&xgc_usr_short_name',
'&map_version'
FROM gc_country@&xgc_usr&_link a,
gc_country_name@&xgc_usr&_link b
WHERE a.comf_id = b.country_id;
COMMIT;

You might also like