The following lines contain the word 'select', 'insert', 'update' or 'delete':
These functions should check for existence by doing select count(*). If none are found, then return zero.
Calling function will perform insertion if value returned is zero. If the object does exist, then this function
will perform a select for the id of the record found; this id is returned as the value from the function. The calling function then knows any non-zero value returned from the function is the id of the existing record.
select bf.balance_feed_id
into already_exists
from pay_balance_feeds_f bf
where bf.balance_type_id = p_bal_id
and bf.input_value_id = p_iv_id
and bf.business_group_id = p_bg_id
and p_eff_date between bf.effective_start_date
and bf.effective_end_date;
select frr.formula_result_rule_id
into already_exists
from pay_formula_result_rules_f frr
where frr.status_processing_rule_id = p_spr_id
and frr.result_name = p_frr_name
and frr.business_group_id = p_bg_id
and nvl(frr.input_value_id, nvl(p_iv_id, 0)) = nvl(p_iv_id, 0)
and nvl(frr.element_type_id, nvl(p_ele_id, 0)) = nvl(p_ele_id, 0)
and p_eff_date between frr.effective_start_date and frr.effective_end_date;
select spr.status_processing_rule_id,
spr.formula_id
into already_exists,
p_ff_id
from pay_status_processing_rules_f spr
where spr.element_type_id = p_ele_id
and spr.assignment_status_type_id IS NULL
and spr.business_group_id = p_bg_id
and p_val_date between spr.effective_start_date
and spr.effective_end_date;
select ff.formula_id,
ff.formula_name,
ff.formula_text
into already_exists,
p_ff_name,
p_ff_text
from pay_element_types_f pet,
pay_status_processing_rules_f spr,
ff_formulas_f ff
where upper(pet.element_name) = upper(p_ele_name)
and pet.business_group_id = p_bg_id
and p_eff_date between pet.effective_start_date
and pet.effective_end_date
and spr.element_type_id = pet.element_type_id
and spr.assignment_status_type_id is null
and spr.business_group_id = p_bg_id
and p_eff_date between spr.effective_start_date
and spr.effective_end_date
and ff.formula_id = spr.formula_id
and ff.business_group_id = p_bg_id
and p_eff_date between ff.effective_start_date
and ff.effective_end_date;
SELECT pdb.defined_balance_id
INTO already_exists
FROM pay_defined_balances pdb
WHERE pdb.balance_type_id = p_bal_id
AND pdb.balance_dimension_id = p_dim_id
AND pdb.business_group_id = p_bg_id;
SELECT piv.input_value_id
INTO already_exists
FROM pay_input_values_f piv
WHERE piv.name = p_iv_name
AND piv.element_type_id = p_ele_id
AND piv.business_group_id = p_bg_id
AND p_eff_date between piv.effective_start_date and piv.effective_end_date;
SELECT pet.element_type_id
INTO already_exists
FROM pay_element_types_f pet
WHERE pet.element_name = p_ele_name
AND pet.business_group_id = p_bg_id
AND p_eff_date between pet.effective_start_date and pet.effective_end_date;
SELECT pbt.balance_type_id
INTO already_exists
FROM pay_balance_types pbt
WHERE pbt.balance_name = p_bal_name
AND pbt.business_group_id = p_bg_id;
select count(0)
into count_exists
from pay_link_input_values_f liv
where liv.element_link_id = p_element_link_id
and liv.input_value_id = p_input_val_id;
select distinct pev.element_entry_value_id
into entry_val_exists
from pay_element_entry_values_f pev
where pev.element_entry_id = p_element_entry_id
and pev.input_value_id = p_input_val_id;
select count(0)
into count_exists
from pay_run_result_values rrv
where rrv.run_result_id = p_run_result_id
and rrv.input_value_id = p_input_val_id;