The following lines contain the word 'select', 'insert', 'update' or 'delete':
SELECT hrl.lookup_code lookup_code,
DECODE(spr.reason, null, 'N', 'Y') exists_flag
FROM hr_standard_lookups hrl,
hri_inv_sprtn_rsns spr
WHERE hrl.lookup_code = spr.reason (+)
AND hrl.lookup_type = 'LEAV_REAS'
UNION ALL
SELECT 'NA_EDW' lookup_code,
'N' exists_flag
FROM dual
WHERE NOT EXISTS
(SELECT -1
FROM hri_inv_sprtn_rsns spr
WHERE spr.reason = 'NA_EDW')
UNION ALL
SELECT 'NA_EDW' lookup_code,
'Y' exists_flag
FROM dual
WHERE EXISTS
(SELECT -1
FROM hri_inv_sprtn_rsns spr
WHERE spr.reason = 'NA_EDW');
dbg('insert/update records in hri_inv_sprtn_rsns');
INSERT
INTO hri_inv_sprtn_rsns
(reason
,termination_type
,update_allowed_flag
)
VALUES (v_leaving_reason.lookup_code
,l_term_type
,'N'
);
UPDATE hri_inv_sprtn_rsns
SET termination_type = l_term_type
WHERE reason = v_leaving_reason.lookup_code;
INSERT /*+ APPEND */ INTO hri_inv_sprtn_rsns
( reason
, termination_type
, update_allowed_flag
, last_update_date
, last_updated_by
, last_update_login
, created_by
, creation_date
)
SELECT
lookup_code
, 'V'
, 'N'
, l_sysdate
, l_user
, l_user
, l_user
, l_sysdate
FROM hr_standard_lookups
WHERE lookup_type = 'LEAV_REAS'
UNION ALL
SELECT
'NA_EDW' lookup_code
, 'V'
, 'N'
, l_sysdate
, l_user
, l_user
, l_user
, l_sysdate
FROM
dual;