The following lines contain the word 'select', 'insert', 'update' or 'delete':
SELECT 'x'
FROM hri_cs_geo_lochr_ct
WHERE rownum < 2;
dbg_time('Insert Start');
INSERT
INTO hri_cs_geo_lochr_ct
(area_code
,country_code
,region_code
,city_cid
,location_id
,geo_area_id
,geo_country_id
,geo_region_id
,city_src_town_or_city_txt
,effective_start_date
,effective_end_date
,business_group_id
,last_change_date
)
SELECT area_code,
country_code,
region_code,
city_cid,
location_id,
geo_area_id,
geo_country_id,
geo_region_id,
city_src_town_or_city_txt,
effective_start_date,
effective_end_date,
business_group_id,
NVL(last_change_date, g_dbi_collection_start_date)
FROM hri_cs_geo_lochr_v svw
--
-- 4303724, Used TRUNC function
--
WHERE TRUNC(last_change_date) BETWEEN g_start_date
AND g_end_date
AND NOT EXISTS (SELECT 'x'
FROM hri_cs_geo_lochr_ct tbl
WHERE svw.location_id = tbl.location_id
AND effective_start_date = tbl.effective_start_date
AND effective_end_date = tbl.effective_end_date)
;
dbg_time('Insert End');
dbg('Insert >'||TO_CHAR(sql%rowcount));
dbg_time('Update Start');
UPDATE hri_cs_geo_lochr_ct tbl
SET
( area_code
,country_code
,region_code
,city_cid
,location_id
,geo_area_id
,geo_country_id
,geo_region_id
,city_src_town_or_city_txt
,effective_start_date
,effective_end_date
,business_group_id
,last_change_date
) =
(SELECT svw.area_code,
svw.country_code,
svw.region_code,
svw.city_cid,
svw.location_id,
svw.geo_area_id,
svw.geo_country_id,
svw.geo_region_id,
svw.city_src_town_or_city_txt,
svw.effective_start_date,
svw.effective_end_date,
svw.business_group_id,
NVL(svw.last_change_date, g_dbi_collection_start_date)
FROM hri_cs_geo_lochr_v svw
WHERE svw.location_id = tbl.location_id
AND ( svw.area_code <> tbl.area_code
OR svw.country_code <> tbl.country_code
OR svw.region_code <> tbl.region_code
OR svw.city_cid <> tbl.city_cid
)
)
WHERE EXISTS
(SELECT 'X'
FROM hri_cs_geo_lochr_v svw
WHERE svw.location_id = tbl.location_id
AND svw.effective_start_date = tbl.effective_start_date
AND svw.effective_end_date = tbl.effective_end_date
AND ( svw.area_code <> tbl.area_code
OR svw.country_code <> tbl.country_code
OR svw.region_code <> tbl.region_code
OR svw.city_cid <> tbl.city_cid
)
)
RETURNING tbl.location_id BULK COLLECT INTO l_upd_location_ids
;
dbg_time('Update End');
dbg('Update >'||TO_CHAR(sql%rowcount));
dbg_time('Delete Start');
DELETE
FROM hri_cs_geo_lochr_ct tbl
WHERE NOT EXISTS
(SELECT 'x'
FROM hri_cs_geo_lochr_v svw
WHERE svw.location_id = tbl.location_id
)
;
dbg_time('Delete End');
dbg('Delete >'||TO_CHAR(sql%rowcount));
dbg_time('Update Event Queue Start');
INSERT INTO HRI_EQ_ASG_SUP_WRFC
(SOURCE_TYPE,
SOURCE_ID)
VALUES
('LOCATION',
l_upd_location_ids(i));
dbg_time('Update Event Queue End');
dbg_time('Update Start');
UPDATE hri_cs_geo_region_ct tbl
SET
( geo_area_code
, geo_country_code
, geo_region_code
, geo_region_sk_pk
, start_date
, end_date
, last_change_date
) =
(SELECT csr.geo_area_code
, csr.geo_country_code
, csr.geo_region_code
, csr.geo_region_sk_pk
, csr.start_date
, csr.end_date
, csr.last_change_date
FROM hri_dbi_cs_geo_region_v csr
WHERE csr.geo_region_sk_pk = tbl.geo_region_sk_pk
AND ( csr.geo_area_code <> tbl.geo_area_code
OR csr.geo_country_code <> tbl.geo_country_code
OR csr.start_date <> tbl.start_date
OR csr.end_date <> tbl.end_date
)
)
WHERE EXISTS
(SELECT 'X'
FROM hri_dbi_cs_geo_region_v csr
WHERE csr.geo_region_sk_pk = tbl.geo_region_sk_pk
AND ( csr.geo_area_code <> tbl.geo_area_code
OR csr.geo_country_code <> tbl.geo_country_code
OR csr.start_date <> tbl.start_date
OR csr.end_date <> tbl.end_date
)
)
;
dbg_time('Update End');
dbg('Update >'||TO_CHAR(sql%rowcount));
dbg_time('Delete Start');
DELETE
FROM hri_cs_geo_region_ct tbl
WHERE NOT EXISTS
(SELECT 'X'
FROM hri_dbi_cs_geo_region_v csr
WHERE csr.geo_region_sk_pk = tbl.geo_region_sk_pk
)
;
dbg_time('Delete End');
dbg('Delete >'||TO_CHAR(sql%rowcount));
dbg_time('Insert Start');
INSERT
INTO hri_cs_geo_region_ct
( geo_area_code
, geo_country_code
, geo_region_code
, geo_region_sk_pk
, start_date
, end_date
, last_change_date
)
SELECT csr.geo_area_code
, csr.geo_country_code
, csr.geo_region_code
, csr.geo_region_sk_pk
, csr.start_date
, csr.end_date
, csr.last_change_date
FROM hri_dbi_cs_geo_region_v csr
WHERE NOT EXISTS
(SELECT 'x'
FROM hri_cs_geo_region_ct tbl
WHERE csr.geo_region_sk_pk = tbl.geo_region_sk_pk
)
;
dbg_time('Insert End');
dbg('Insert >'||TO_CHAR(sql%rowcount));
Output('Failure in region structure incremental update process.');
dbg_time('Update Start');
UPDATE hri_cs_geo_country_ct tbl
SET
( geo_area_code
, geo_country_code
, start_date
, end_date
, last_change_date
) =
(SELECT csc.geo_area_code
, csc.geo_country_code
, csc.start_date
, csc.end_date
, csc.last_change_date
FROM hri_dbi_cs_geo_country_v csc
WHERE csc.geo_country_code = tbl.geo_country_code
AND ( csc.geo_area_code <> tbl.geo_area_code
OR csc.start_date <> tbl.start_date
OR csc.end_date <> tbl.end_date
)
)
WHERE EXISTS
(SELECT 'X'
FROM hri_dbi_cs_geo_country_v csc
WHERE csc.geo_country_code = tbl.geo_country_code
AND ( csc.geo_area_code <> tbl.geo_area_code
OR csc.start_date <> tbl.start_date
OR csc.end_date <> tbl.end_date
)
)
;
dbg_time('Update End');
dbg('Update >'||TO_CHAR(sql%rowcount));
dbg_time('Delete Start');
DELETE
FROM hri_cs_geo_country_ct tbl
WHERE NOT EXISTS
(SELECT 'x'
FROM hri_dbi_cs_geo_country_v csc
WHERE csc.geo_country_code = tbl.geo_country_code
)
;
dbg_time('Delete End');
dbg('Delete >'||TO_CHAR(sql%rowcount));
dbg_time('Insert Start');
INSERT
INTO hri_cs_geo_country_ct
( geo_area_code
, geo_country_code
, start_date
, end_date
, last_change_date
)
SELECT csc.geo_area_code
, csc.geo_country_code
, csc.start_date
, csc.end_date
, csc.last_change_date
FROM hri_dbi_cs_geo_country_v csc
WHERE NOT EXISTS
(SELECT 'x'
FROM hri_cs_geo_country_ct tbl
WHERE csc.geo_country_code = tbl.geo_country_code
)
;
dbg_time('Insert End');
dbg('Insert >'||TO_CHAR(sql%rowcount));
Output('Failure in country structure incremental update process.');
dbg_time('Insert Start');
INSERT /*+ APPEND */
INTO hri_cs_geo_lochr_ct
(area_code
,country_code
,region_code
,city_cid
,location_id
,geo_area_id
,geo_country_id
,geo_region_id
,city_src_town_or_city_txt
,effective_start_date
,effective_end_date
,business_group_id
,last_change_date
,last_update_date
,last_update_login
,last_updated_by
,created_by
,creation_date
)
SELECT area_code,
country_code,
region_code,
city_cid,
location_id,
geo_area_id,
geo_country_id,
geo_region_id,
city_src_town_or_city_txt,
effective_start_date,
effective_end_date,
business_group_id,
NVL(last_change_date, g_dbi_collection_start_date),
g_current_time,
g_user_id,
g_user_id,
g_user_id,
g_current_time
FROM hri_cs_geo_lochr_v svw
;
dbg_time('Insert End');
dbg_time('Insert Start');
INSERT /*+APPEND */
INTO hri_cs_geo_region_ct
( geo_area_code
, geo_country_code
, geo_region_code
, geo_region_sk_pk
, start_date
, end_date
, LAST_CHANGE_DATE
, CREATION_DATE
, CREATED_BY
, LAST_UPDATE_DATE
, LAST_UPDATED_BY
, LAST_UPDATE_LOGIN
)
SELECT csr.geo_area_code geo_area_code
, csr.geo_country_code geo_country_code
, csr.geo_region_code geo_region_code
, csr.geo_region_sk_pk geo_region_sk_pk
, csr.start_date start_date
, csr.end_date end_date
, csr.last_change_date last_change_date
, g_current_time CREATION_DATE
, g_user_id CREATED_BY
, g_current_time LAST_UPDADTE_DATE
, g_user_id LAST_UPDATE_BY
, g_user_id LAST_UPDATE_LOGIN
FROM hri_dbi_cs_geo_region_v csr
;
dbg_time('Insert End');
dbg_time('Insert Start');
INSERT /*+APPEND */
INTO hri_cs_geo_country_ct
( geo_area_code
, geo_country_code
, start_date
, end_date
, LAST_CHANGE_DATE
, CREATION_DATE
, CREATED_BY
, LAST_UPDATE_DATE
, LAST_UPDATED_BY
, LAST_UPDATE_LOGIN
)
SELECT csc.geo_area_code geo_area_code
, csc.geo_country_code geo_country_code
, csc.start_date start_date
, csc.end_date end_date
, csc.last_change_date last_change_date
, g_current_time CREATION_DATE
, g_user_id CREATED_BY
, g_current_time LAST_UPDATE_DATE
, g_user_id LAST_UPDATED_BY
, g_user_id LAST_UPDATE_LOGIN
FROM hri_dbi_cs_geo_country_v csc
;
dbg_time('Insert End');