DBA Data[Home] [Help]

APPS.HR_LEGISLATION_ELEMENTS SQL Statements

The following lines contain the word 'select', 'insert', 'update' or 'delete':

Line: 13

    l_null_return varchar2(1); 		-- For 'select null' statements
Line: 16

    CURSOR stu				-- Selects all rows from startup entity
    IS
	select classification_name c_true_key
	,      rowid
	,      classification_id c_surrogate_key
	,      legislation_code c_leg_code
	,      legislation_subgroup c_leg_sgrp
	,      business_group_id
	,      description
	,      costing_debit_or_credit
	,      default_high_priority
	,      default_low_priority
	,      default_priority
	,      distributable_over_flag
	,      non_payments_flag
	,      parent_classification_id
	,      costable_flag
	,      create_by_default_flag
	,      last_update_date
	,      last_updated_by
	,      last_update_login
	,      created_by
	,      creation_date
        ,      balance_initialization_flag
        ,      FREQ_RULE_ENABLED
	from   hr_s_element_classifications
	order  by parent_classification_id desc;
Line: 61

	hr_legislation.insert_hr_stu_exceptions('pay_element_classifications'
        ,      stu_rec.c_surrogate_key
        ,      exception_type
        ,      stu_rec.c_true_key);
Line: 80

	-- 1. Where the newly select sequence value conflicts with values
	--    in the STU tables.
	-- 2. Where selected surrogate keys, from the installed tables,
	--    conflict with other rows in the STU tables.
	--
	-- Both of the above scenario's are tested for.
	-- The first is a simple match, where if a value is detected in the
	-- STU tables and the installed tables then a conflict is detected. In
	-- This instance all STU surrogate keys, for this table, are updated.
	-- The second is tested for using the sequences.
	-- If the next value from the live sequence is within the range of
	-- delivered surrogate id's then the live sequence must be incremented.
	-- If no action is taken, then duplicates may be introduced into the
	-- delivered tables, and child rows may be totally invalidated.

    BEGIN


	BEGIN	--check that the installed id's will not conflict
		--with the delivered values


	    select distinct null
	    into   l_null_return
	    from   pay_element_classifications a
	    where  exists
		(select null
		 from   hr_s_element_classifications b
		 where  a.classification_id = b.classification_id
		);
Line: 112

	    --update all classification_id's to remove conflict

	    update /*+NO_INDEX*/ hr_s_element_classifications
	    set    classification_id = classification_id - 50000000
	    ,parent_classification_id = parent_classification_id - 50000000;
Line: 118

            update /*+NO_INDEX*/ hr_s_BALANCE_CLASSIFICATIONS
            set    classification_id = classification_id - 50000000;
Line: 121

            update /*+NO_INDEX*/ hr_s_ELEMENT_TYPES_F
            set    classification_id = classification_id - 50000000;
Line: 124

            update /*+NO_INDEX*/ hr_s_ELE_CLASSN_RULES
            set    classification_id = classification_id - 50000000;
Line: 127

            update /*+NO_INDEX*/ hr_s_SUB_CLASSN_RULES_F
            set    classification_id = classification_id - 50000000;
Line: 134

            update /*+NO_INDEX*/ hr_s_TAXABILITY_RULES
            set    classification_id = classification_id - 50000000;
Line: 137

	    update hr_s_application_ownerships
	    set    key_value = key_value - 50000000
	    where  key_name = 'CLASSIFICATION_ID';
Line: 147

	select min(classification_id) - (count(*) *3)
	,      max(classification_id) + (count(*) *3)
	into   v_min_delivered
	,      v_max_delivered
	from   hr_s_element_classifications;
Line: 153

	select pay_element_classifications_s.nextval
	into   v_sequence_number
	from   dual;
Line: 175

	-- every foriegn key. The first select from the delivery tables.

	-- If a row is founnd then the installation of the parent must have
	-- failed, and this installation must not go ahead. If no data is
	-- found, ie: an exception is raised, the installation is valid.

	-- The second check looks for a row in the live tables. If no rows
	-- are returned then this installation is invalid, since this means
	-- that the parent referenced by this row is not present in the
	-- live tables.

	-- The distinct is used in case the parent is date effective and many rows
	-- may be returned by the same parent id.


	IF stu_rec.parent_classification_id is null THEN
	    -- No need to check parent
	    return TRUE;
Line: 199

	    select distinct null
	    into   l_null_return
	    from   hr_s_element_classifications
	    where  classification_id = stu_rec.parent_classification_id;
Line: 221

	    select null
	    into   l_null_return
	    from   pay_element_classifications
	    where  classification_id = stu_rec.parent_classification_id;
Line: 239

    PROCEDURE update_uid
    --------------------
    IS
	-- Subprogram to update surrogate UID and all occurrences in child rows

    BEGIN

	BEGIN


	    select distinct classification_id
	    into   l_new_surrogate_key
	    from   pay_element_classifications
	    where  classification_name = stu_rec.c_true_key
	    and    business_group_id is null
            and  ( (legislation_code is null
                    and  stu_rec.c_leg_code is null)
                or (legislation_code = stu_rec.c_leg_code) );
Line: 261

	    select pay_element_classifications_s.nextval
	    into   l_new_surrogate_key
	    from   dual;
Line: 278

	-- Update all child entities

   	update hr_s_element_classifications
   	set    classification_id = l_new_surrogate_key
   	where  classification_id = stu_rec.c_surrogate_key;
Line: 284

   	update hr_s_element_classifications
   	set    parent_classification_id = l_new_surrogate_key
   	where  parent_classification_id = stu_rec.c_surrogate_key;
Line: 288

   	update hr_s_application_ownerships
   	set    key_value = to_char(l_new_surrogate_key)
   	where  key_value = to_char(stu_rec.c_surrogate_key)
   	and    key_name = 'CLASSIFICATION_ID';
Line: 293

   	update hr_s_element_types_f
   	set    classification_id = l_new_surrogate_key
   	where  classification_id = stu_rec.c_surrogate_key;
Line: 297

   	update hr_s_balance_classifications
   	set    classification_id = l_new_surrogate_key
   	where  classification_id = stu_rec.c_surrogate_key;
Line: 301

   	update hr_s_sub_classn_rules_f
   	set    classification_id = l_new_surrogate_key
   	where  classification_id = stu_rec.c_surrogate_key;
Line: 305

   	update hr_s_ele_classn_rules
   	set    classification_id = l_new_surrogate_key
   	where  classification_id = stu_rec.c_surrogate_key;
Line: 309

   	update hr_s_taxability_rules
   	set    classification_id = l_new_surrogate_key
   	where  classification_id = stu_rec.c_surrogate_key;
Line: 313

    END update_uid;
Line: 323

	delete from hr_s_element_classifications
	where  rowid = stu_rec.rowid;
Line: 332

	  delete from hr_s_taxability_rules
	  where  classification_id = stu_rec.c_surrogate_key;
Line: 345

	-- then this row is not required and may be deleted from the delivery
	-- tables.

	-- If legislation code and subgroup code are included on the delivery
	-- tables, a check must be made to determine if the data is defined for
	-- a specific subgroup. If so the subgroup must be 'A'ctive for this
	-- installation.

	-- A return code of TRUE indicates that the row is required.

	-- The exception is raised within this procedure if no rows are returned
	-- in this select statement. If no rows are returned then one of the
	-- following is true:
	--     1. No ownership parameters are defined.
	--     2. The products, for which owning parameters are defined, are not
	--        installed with as status of 'I'.
	--     3. The data is defined for a legislation subgroup that is not active.

    BEGIN

	IF p_phase <> 1 THEN	--only perform in phase 1
		return TRUE;
Line: 372

        select null
        into   l_null_return
        from   dual
        where  exists
        (select null
        from   hr_s_application_ownerships a
        ,      fnd_product_installations b
        ,      fnd_application c
        where  a.key_name = 'CLASSIFICATION_ID'
        and    a.key_value = stu_rec.c_surrogate_key
        and    a.product_name = c.application_short_name
        and    c.application_id = b.application_id
        and    ((b.status = 'I' and c.application_short_name <> 'PQP')
                or
                (b.status in ('I', 'S') and c.application_short_name = 'PQP')));
Line: 388

 	select null
	into   l_null_return
	from   dual
	where  exists
	(select null
	from   hr_s_application_ownerships a
	,      fnd_product_installations b
	,      fnd_application c
	where  a.key_name = 'CLASSIFICATION_ID'
	and    a.key_value = stu_rec.c_surrogate_key
	and    a.product_name = c.application_short_name
	and    c.application_id = b.application_id
        and    ((b.status = 'I' and c.application_short_name <> 'PQP')
                or
                (b.status in ('I', 'S') and c.application_short_name = 'PQP')))
	and exists (select null from hr_legislation_subgroups d
	         where d.legislation_code = stu_rec.c_leg_code
	     and  d.legislation_subgroup = stu_rec.c_leg_sgrp
	     and  d.active_inactive_flag = 'A'
	         );
Line: 428

	-- Check if a delivered row is needed and insert into the
	-- live tables if it is

    BEGIN

	BEGIN
	    -- Perform a check to see if the primary key has been created within
	    -- a visible business group. Ie: the business group is for the same
	    -- legislation as the delivered row, or the delivered row has a null
	    -- legislation. If no rows are returned then the primary key has not
	    -- already been created by a user.

            select distinct null
            into   l_null_return
            from pay_element_classifications a
            where a.classification_name = stu_rec.c_true_key
            and   a.business_group_id is not null
            and   exists (select null from per_business_groups b
              where b.business_group_id = a.business_group_id
              and b.legislation_code = nvl(stu_rec.c_leg_code,b.legislation_code));
Line: 474

            select distinct null
            into   l_null_return
            from   pay_element_classifications
            where  classification_name = stu_rec.c_true_key
            and    nvl(legislation_code,'x') <> nvl(stu_rec.c_leg_code,'x')
            and   (legislation_code is null or stu_rec.c_leg_code is null )
	    and    business_group_id is null;
Line: 500

	-- If the procedure is called in phase 2, then the live row is updated
	-- with the values on the delivered row.

	-- The routine check_parents validates foreign key references and
	-- ensures referential integrity. The routine checks to see if the
	-- parents of a given row have been transfered to the live tables.

	-- This may only be called in phase two since in phase one all
	-- parent rows will remain in the delivery tables.

	-- After the above checks only data that has been chanegd or is new
	-- will be left in the delivery tables. At this stage if the row is
	-- already present then it must be updated to ensure referential
	-- integrity. Therefore an update will be performed and if SQL%FOUND
	-- is FALSE an insert will be performed.

	-- The last step of the transfer, in phase 2, is to delete the now
	-- transfered row from the delivery tables.

   	IF p_phase = 1 THEN
	    return;
Line: 529

   	update pay_element_classifications
   	set    classification_name = stu_rec.c_true_key
   	,      legislation_code = stu_rec.c_leg_code
   	,      legislation_subgroup = stu_rec.c_leg_sgrp
   	,      business_group_id = stu_rec.business_group_id
   	,      description = stu_rec.description
   	,      costing_debit_or_credit = stu_rec.costing_debit_or_credit
   	,      default_high_priority = stu_rec.default_high_priority
  	,      default_low_priority = stu_rec.default_low_priority
  	,      default_priority = stu_rec.default_priority
   	,      distributable_over_flag = stu_rec.distributable_over_flag
   	,      non_payments_flag = stu_rec.non_payments_flag
   	,      parent_classification_id = stu_rec.parent_classification_id
   	,      costable_flag = stu_rec.costable_flag
   	,      create_by_default_flag = stu_rec.create_by_default_flag
   	,      last_update_date = stu_rec.last_update_date
  	,      last_updated_by = stu_rec.last_updated_by
   	,      last_update_login = stu_rec.last_update_login
   	,      created_by = stu_rec.created_by
   	,      creation_date = stu_rec.creation_date
        ,      balance_initialization_flag = stu_rec.balance_initialization_flag
        ,      FREQ_RULE_ENABLED = stu_rec.FREQ_RULE_ENABLED
   	where  classification_id = stu_rec.c_surrogate_key;
Line: 556

	    insert into pay_element_classifications
	    (classification_name
	    ,classification_id
	    ,legislation_code
	    ,legislation_subgroup
	    ,business_group_id
	    ,description
	    ,costing_debit_or_credit
	    ,default_high_priority
	    ,default_low_priority
	    ,default_priority
	    ,distributable_over_flag
	    ,non_payments_flag
	    ,parent_classification_id
	    ,costable_flag
	    ,create_by_default_flag
	    ,last_update_date
	    ,last_updated_by
	    ,last_update_login
	    ,created_by
	    ,creation_date
            ,balance_initialization_flag
            ,FREQ_RULE_ENABLED
	    )
	    values
	    (stu_rec.c_true_key
	    ,stu_rec.c_surrogate_key
	    ,stu_rec.c_leg_code
	    ,stu_rec.c_leg_sgrp
	    ,stu_rec.business_group_id
	    ,stu_rec.description
	    ,stu_rec.costing_debit_or_credit
	    ,stu_rec.default_high_priority
	    ,stu_rec.default_low_priority
	    ,stu_rec.default_priority
	    ,stu_rec.distributable_over_flag
	    ,stu_rec.non_payments_flag
	    ,stu_rec.parent_classification_id
	    ,stu_rec.costable_flag
	    ,stu_rec.create_by_default_flag
	    ,stu_rec.last_update_date
	    ,stu_rec.last_updated_by
	    ,stu_rec.last_update_login
	    ,stu_rec.created_by
	    ,stu_rec.creation_date
            ,stu_rec.balance_initialization_flag
            ,stu_rec.FREQ_RULE_ENABLED);
Line: 657

		update_uid;
Line: 699

	-- Select distinct element names. The element name can no longer be
	-- guarenteed to be unique. This cursor selects all distinct names
	-- for the next cusrsor to select distinct element_type_id's from.

   	select distinct element_name
   	from   hr_s_element_types_f;
Line: 709

	-- This row is then used to select all date effective rows for this id.

	select max(effective_end_date) c_end
	,      min(effective_start_date) c_start
	,      element_type_id c_surrogate_key
	,      element_name c_true_key
	,      legislation_code
	,      legislation_subgroup
        ,      nvl(new_element_type_flag, 'Y') new_element_type_flag
	from   hr_s_element_types_f
	where  element_name = pc_ele_name
	group  by element_type_id
	,         element_name
	,         legislation_code
	,         legislation_subgroup
        ,         nvl(new_element_type_flag, 'Y');
Line: 728

	-- Selects all date effective rows for the current true primary key

	-- The primary key has already been selected using the above cursor.
	-- This cursor accepts the primary key as a parameter and selects all
	-- date effective rows for it.

   	select *
   	from   hr_s_element_types_f
   	where  element_type_id = pc_element_type_id;
Line: 742

   	select *
   	from   hr_s_sub_classn_rules_f
   	where  element_type_id = pc_element_id;
Line: 749

	-- Used for the update of uid's.
	--
	-- #346366. Also pull back the assignment_status_type_id, as we
	-- could have different rules for different statuses for the
	-- same element type.
	--
   	select distinct status_processing_rule_id s_rule_id,
	       assignment_status_type_id,processing_rule
   	from   hr_s_status_processing_rules_f
   	where  element_Type_id = pc_element_id;
Line: 762

	-- Retrieves full details of processing rules for the insertiion into
	-- live tables.

   	select *
   	from   hr_s_status_processing_rules_f
   	where  status_processing_rule_id = pc_stat_rule_id;
Line: 773

   	select *
   	from   hr_s_formula_result_rules_f
   	where  status_processing_rule_id = pc_stat_rule_id;
Line: 782

   	select distinct formula_result_rule_id
   	from   hr_s_formula_result_rules_f
   	where  status_processing_rule_id = pc_stat_rule_id;
Line: 790

   	select distinct input_value_id
   	,      name
        ,      value_set_name
        ,      new_input_value_flag
   	from   hr_s_input_values_f
   	where  element_Type_id = pc_element_id;
Line: 798

	-- values selected. This saves the need for all sub procedures to have
	-- a myriad of parameters passed. The cursors are controlled in FOR
	-- cursor LOOPs. When a row is returned the whole record is copied into
	-- these record definitions.

	r_distinct c_distinct_element%ROWTYPE;
Line: 816

	-- 1. Where the newly select sequence value conflicts with values
	--    in the STU tables.
	-- 2. Where selected surrogate keys, from the installed tables,
	--    conflict with other rows in the STU tables.
	--
	-- Both of the above scenario's are tested for.
	-- The first is a simple match, where if a value is detected in the
	-- STU tables and the installed tables then a conflict is detected. In
	-- This instance all STU surrogate keys, for this table, are updated.
	-- The second is tested for using the sequences.
	-- If the next value from the live sequence is within the range of
	-- delivered surrogate id's then the live sequence must be incremented.
	-- If no action is taken, then duplicates may be introduced into the
	-- delivered tables, and child rows may be totally invalidated.

    BEGIN


	BEGIN	--check that the installed id's will not conflict
		--with the delivered values


	    select distinct null
	    into   l_null_return
	    from   pay_element_types_f a
	    where  exists
		(select null
		 from   hr_s_element_types_f b
		 where  a.element_type_id = b.element_type_id
		);
Line: 848

	    --update all element_type_id's to remove conflict

	    update /*+NO_INDEX*/ hr_s_ELEMENT_TYPES_F
	    set    element_type_id = element_type_id - 50000000,
                   retro_summ_ele_id = retro_summ_ele_id - 50000000;
Line: 854

            update /*+NO_INDEX*/ hr_s_ELEMENT_TYPE_RULES
            set    element_type_id = element_type_id - 50000000;
Line: 857

            update /*+NO_INDEX*/ hr_s_FORMULA_RESULT_RULES_F
            set    element_type_id = element_type_id - 50000000;
Line: 860

            update /*+NO_INDEX*/ hr_s_INPUT_VALUES_F
            set    element_type_id = element_type_id - 50000000;
Line: 863

            update /*+NO_INDEX*/ hr_s_STATUS_PROCESSING_RULES_F
            set    element_type_id = element_type_id - 50000000;
Line: 866

            update /*+NO_INDEX*/ hr_s_SUB_CLASSN_RULES_F
            set    element_type_id = element_type_id - 50000000;
Line: 869

	    update hr_s_application_ownerships
	    set    key_value = key_value - 50000000
	    where  key_name = 'ELEMENT_TYPE_ID';
Line: 881

	    select distinct null
	    into   l_null_return
	    from   pay_input_values_f a
	    where  exists
		(select null
		 from   hr_s_input_values_f b
		 where  a.input_value_id = b.input_value_id
		);
Line: 891

	    --update all input_value_id's to remove conflict

	    update /*+NO_INDEX*/ hr_s_INPUT_VALUES_F
            set    input_value_id = input_value_id - 50000000;
Line: 896

	    update /*+NO_INDEX*/ hr_s_BALANCE_FEEDS_F
	    set    input_value_id = input_value_id - 50000000;
Line: 899

            update /*+NO_INDEX*/ hr_s_FORMULA_RESULT_RULES_F
            set    input_value_id = input_value_id - 50000000;
Line: 902

            update /*+NO_INDEX*/ hr_s_balance_types
            set    input_value_id = input_value_id - 50000000;
Line: 907

	    -- the update STU_FORMULA_RESULT_RULES_F statement immediately
	    -- above, resulting in the input_value_id being decremented
	    -- twice, thereby breaking the fkey link.
	    --

	EXCEPTION WHEN NO_DATA_FOUND THEN NULL;
Line: 920

	    select distinct null
	    into   l_null_return
	    from   pay_status_processing_rules_f a
	    where  exists
		(select null
		 from   hr_s_status_processing_rules_f b
		 where  a.status_processing_rule_id=b.status_processing_rule_id
		);
Line: 930

	    --update all status_processing_rule_id's to remove conflict

	    update hr_s_FORMULA_RESULT_RULES_F
	    set status_processing_rule_id=status_processing_rule_id-50000000;
Line: 935

            update hr_s_STATUS_PROCESSING_RULES_F
            set status_processing_rule_id=status_processing_rule_id-50000000;
Line: 946

	    select distinct null
	    into   l_null_return
	    from   pay_formula_result_rules_f a
	    where  exists
		(select null
		 from   hr_s_formula_result_rules_f b
		 where  a.formula_result_rule_id = b.formula_result_rule_id
		);
Line: 956

	    --update all formula_result_rule_id's to remove conflict

	    update /*+NO_INDEX*/ hr_s_FORMULA_RESULT_RULES_F
	    set    formula_result_rule_id = formula_result_rule_id - 50000000;
Line: 969

	    select distinct null
	    into   l_null_return
	    from   pay_sub_classification_rules_f a
	    where  exists
		(select null
		 from   hr_s_sub_classn_rules_f b
		 where a.sub_classification_rule_id=b.sub_classification_rule_id
		);
Line: 979

	    --update all sub_classification_rule_id's to remove conflict

	    update /*+NO_INDEX*/ hr_s_sub_classn_rules_f
	    set sub_classification_rule_id=sub_classification_rule_id-50000000;
Line: 990

	select min(element_type_id) - (count(*) *3)
	,      max(element_type_id) + (count(*) *3)
	into   v_min_delivered
	,      v_max_delivered
	from   hr_s_element_types_f;
Line: 996

	select pay_element_types_s.nextval
	into   v_sequence_number
	from   dual;
Line: 1005

	    select pay_element_types_s.nextval
            into   v_sequence_number
            from   dual;
Line: 1014

	select min(input_value_id) - (count(*) *3)
	,      max(input_value_id) + (count(*) *3)
	into   v_min_delivered
        ,      v_max_delivered
	from   hr_s_input_values_f;
Line: 1020

	select pay_input_Values_s.nextval
        into   v_sequence_number
        from   dual;
Line: 1036

        select min(status_processing_rule_id) - (count(*) *3)
        ,      max(status_processing_rule_id) + (count(*) *3)
        into   v_min_delivered
        ,      v_max_delivered
        from   hr_s_status_processing_rules_f;
Line: 1042

        select pay_status_processing_rules_s.nextval
        into   v_sequence_number
        from   dual;
Line: 1058

        select min(formula_result_rule_id) - (count(*) *3)
        ,      max(formula_result_rule_id) + (count(*) *3)
        into   v_min_delivered
        ,      v_max_delivered
        from   hr_s_formula_result_rules_f;
Line: 1064

        select pay_formula_result_rules_s.nextval
        into   v_sequence_number
        from   dual;
Line: 1081

        select min(sub_classification_rule_id) - (count(*) *3)
        ,      max(sub_classification_rule_id) + (count(*) *3)
        into   v_min_delivered
        ,      v_max_delivered
        from   hr_s_sub_classn_rules_f;
Line: 1087

        select pay_sub_classification_rules_s.nextval
        into   v_sequence_number
        from   dual;
Line: 1124

	hr_legislation.insert_hr_stu_exceptions('pay_element_types_f'
        ,      r_distinct.c_surrogate_key
        ,      exception_type
        ,      r_distinct.c_true_key);
Line: 1135

	-- Subprogram to delete a row from the delivery tables, and all child
	-- application ownership rows

    BEGIN

   	delete from hr_s_element_types_f
   	where  element_type_id = v_id;
Line: 1143

   	delete from hr_s_sub_classn_rules_f
   	where  element_type_id = v_id;
Line: 1146

   	delete from hr_s_input_values_f
   	where  element_type_id = v_id;
Line: 1149

   	delete from hr_s_formula_result_rules_f a
   	where  exists
          (select null
           from   hr_s_status_processing_rules_f b
           where  b.status_processing_rule_id = a.status_processing_rule_id
           and    b.element_type_id = v_id
          );
Line: 1157

   	delete from hr_s_status_processing_rules_f
   	where  element_type_id = v_id;
Line: 1162

    PROCEDURE update_uid
    --------------------
    IS
	-- Subprogram to update surrogate UID and all occurrences in child rows

	v_new_sub_class_id number(15);
Line: 1178

	-- key of the delivered row must be updated to the value in the installed
	-- tables. If the row is not already present then select the next value
	-- from the sequence. In either case all rows for this primary key must
	-- be updated, as must all child references to the old surrogate uid.


   	BEGIN
	    select distinct element_type_id
	    into   l_new_element_type_id
	    from   pay_element_types_f
            where  replace(ltrim(rtrim(upper(element_name))), ' ', '_') =
                   replace(ltrim(rtrim(upper(r_distinct.c_true_key))), ' ', '_')
	    and    business_Group_id is null
	    and    legislation_code = r_distinct.legislation_code;
Line: 1198

	    select pay_element_types_s.nextval
	    into   l_new_element_type_id
	    from   dual;
Line: 1215

   	update hr_s_element_types_f
   	set    element_type_id = l_new_element_type_id,
               new_element_type_flag = v_new_element_type_flag
   	where  element_type_id = r_distinct.c_surrogate_key;
Line: 1220

        update hr_s_element_types_f
        set    retro_summ_ele_id = l_new_element_type_id
        where  retro_summ_ele_id = r_distinct.c_surrogate_key;
Line: 1224

   	update hr_s_element_type_rules
   	set    element_type_id = l_new_element_type_id
   	where  element_type_id = r_distinct.c_surrogate_key;
Line: 1228

   	update hr_s_formula_result_rules_f
   	set    element_type_id = l_new_element_type_id
   	where  element_type_id = r_distinct.c_surrogate_key;
Line: 1232

   	update hr_s_application_ownerships
   	set    key_value = to_char(l_new_element_type_id)
   	where  key_value = to_char(r_distinct.c_surrogate_key)
   	and    key_name = 'ELEMENT_TYPE_ID';
Line: 1237

   	-- update the uid of associated input values

   	FOR i_vals IN inputs(r_distinct.c_surrogate_key) LOOP


	    BEGIN
		-- Test if input value already exists
		-- #331823. Add 'distinct' to prevent a 'too many rows'
		--          error if there is more than one datetracked
		--          version of the input values row.

	   	select distinct input_value_id
	   	into   v_new_input_id
	   	from   pay_input_values_f
                where  replace(ltrim(rtrim(upper(name))), ' ', '_') =
                       replace(ltrim(rtrim(upper(i_vals.name))), ' ', '_')
	   	and    business_group_id is null
	   	and    element_type_id = l_new_element_Type_id;
Line: 1260

		select pay_input_values_s.nextval
		into   v_new_input_id
		from   dual;
Line: 1279

	    update hr_s_input_values_f
	    set    input_value_id = v_new_input_id
	    ,      element_type_id = l_new_element_type_id
	    ,      new_input_value_flag = v_new_input_value_flag
	    where  input_value_id = i_vals.input_value_id;
Line: 1285

	    update hr_s_balance_feeds_f
	    set    input_value_id = v_new_input_id,
                   new_input_value_flag = v_new_input_value_flag
	    where  input_value_id = i_vals.input_value_id;
Line: 1290

	    update hr_s_formula_result_rules_f
            set    input_value_id = v_new_input_id
            where  input_value_id = i_vals.input_value_id;
Line: 1294

            update hr_s_balance_types
            set    input_value_id = v_new_input_id
            where  input_value_id = i_vals.input_value_id;
Line: 1304

	    select pay_sub_classification_rules_s.nextval
	    into   v_new_sub_class_id
	    from dual;
Line: 1308

	    update hr_s_sub_classn_rules_f
	    set    sub_classification_rule_id = v_new_sub_class_id
	    ,      element_type_id = l_new_element_type_id
	    where  sub_classification_rule_id = s_class.sub_classification_rule_id;
Line: 1315

               select sub_classification_rule_id
               into v_dummy
               from hr_s_sub_classn_rules_f hscr
               where hscr.sub_classification_rule_id = v_new_sub_class_id
               and exists
                 ( select 1
                   from pay_sub_classification_rules_f pscr
                   where pscr.element_type_id = hscr.element_type_id
                   and   pscr.classification_id = hscr.classification_id
                   and   nvl(pscr.business_group_id, -1) = nvl(hscr.business_group_id, -1)
                   and   nvl(pscr.legislation_code, 'X') = nvl(hscr.legislation_code, 'X')
                   and   pscr.effective_start_date = hscr.effective_start_date
                   and   pscr.effective_end_date = hscr.effective_end_date);
Line: 1337

	    update hr_s_sub_classn_rules_f
	    set    new_sub_class_rule_flag = v_new_sub_class_rule_flag
	    where  sub_classification_rule_id = s_class.sub_classification_rule_id;
Line: 1365

  		select distinct status_processing_rule_id
		into   v_new_spr_id
		from   pay_status_processing_rules_f spr
        	where  spr.legislation_code = r_distinct.legislation_code
		and    spr.business_group_id is null
                and    spr.processing_rule = sprs.processing_rule
                and    ((spr.assignment_status_type_id is null
                        and
                        sprs.assignment_status_type_id is null)
                       or
                       (spr.assignment_status_type_id =
                        sprs.assignment_status_type_id))
                and    spr.effective_end_date = (select max(spr2.effective_end_date)
                                                 from  pay_status_processing_rules_f spr2
                                                 where spr2.element_type_id = spr.element_type_id
                                                 and spr2.processing_rule = spr.processing_rule
                                                 and   spr2.legislation_code = r_distinct.legislation_code
		                                 and   spr2.business_group_id is null
		                                 and   ((spr.assignment_status_type_id is null
                                                         and spr2.assignment_status_type_id is null)
                                                        or
                                                        (spr.assignment_status_type_id =
                                                         spr2.assignment_status_type_id)))
		and   element_type_id = l_new_element_type_id;
Line: 1394

		select pay_status_processing_rules_s.nextval
		into   v_new_spr_id
		from   dual;
Line: 1410

	    update hr_s_status_processing_rules_f
	    set    status_processing_rule_id = v_new_spr_id
	    ,      element_type_id = l_new_element_type_id
	    where  status_processing_rule_id = sprs.s_rule_id;
Line: 1417

	       select pay_formula_Result_rules_s.nextval
	       into   v_new_frr_id
	       from   dual;
Line: 1421

	       update hr_s_formula_result_rules_f
	       set    formula_result_rule_id = v_new_frr_id
	       ,      status_processing_rule_id = v_new_spr_id
	       where  formula_result_rule_id = results.formula_result_rule_id;
Line: 1430

    END update_uid;
Line: 1450

	    select distinct null
	    into   l_null_return
	    from   pay_balance_feeds_f a
	    ,      pay_input_values_f b
	    where  b.element_type_id = l_new_element_type_id
	    and    a.input_value_id = b.input_value_id
	    and    a.effective_end_Date > r_distinct.c_end
	    and    a.business_group_id is not null;
Line: 1474

            select distinct null
            into   l_null_return
            from   pay_element_links_f
            where  element_type_id = l_new_element_type_id
            and    effective_end_Date > r_distinct.c_end
	    and    business_group_id is not null;
Line: 1495

            select distinct null
            into   l_null_return
            from   pay_status_processing_rules_f a
	    ,      pay_formula_result_rules_f b
            where  a.element_type_id = l_new_element_type_id
	    and    b.status_processing_rule_id = a.status_processing_rule_id
            and    b.effective_end_Date > r_distinct.c_end
	    and    b.business_group_id is not null;
Line: 1520

              select input_value_id
              into   l_input_value_id
              from   pay_input_values_f
              where  element_type_id = l_new_element_type_id
              and    rownum = 1;
Line: 1537

              select 1
              into   l_null_return
              from   dual
              where exists
              (select /*+ ORDERED INDEX(a PAY_RUN_RESULTS_PK)
                         USE_NL(a b c) */ null
              from   pay_run_result_values v
              ,      pay_run_results a
              ,      pay_assignment_actions b
              ,      pay_payroll_actions c
              where  v.input_value_id = l_input_value_id
              and    a.run_result_id = v.run_result_id
              and    b.assignment_action_id = a.assignment_action_id
              and    c.payroll_action_id = b.payroll_action_id
              and    c.effective_date > r_distinct.c_end);
Line: 1555

              select 1
	      into   l_null_return
              from   dual
              where exists
	      (select null
	      from   pay_run_results a
	      ,      pay_assignment_actions b
	      ,      pay_payroll_actions c
	      where  a.element_Type_id = l_new_element_type_id
	      and    b.assignment_action_id = a.assignment_action_id
	      and    c.payroll_action_id = b.payroll_action_id
	      and    c.effective_date > r_distinct.c_end);
Line: 1597

	-- every foriegn key. The first select from the delivery tables.

	-- If a row is founnd then the installation of the parent must have
	-- failed, and this installation must not go ahead. If no data is
	-- found, ie: an exception is raised, the installation is valid.

	-- The second check looks for a row in the live tables. If no rows
	-- are returned then this installation is invalid, since this means
	-- that the parent referenced by this row is not present in the
	-- live tables.

	-- Return code of true indicates that all parental data is correct.

    BEGIN


	-- Start first parent check

   	BEGIN

	    -- Check first parent does not exist in the delivery tables

	    select null
	    into   l_null_return
	    from   hr_s_element_classifications
	    where  classification_id  = r_each_row.classification_id;
Line: 1642

	    select null
	    into   l_null_return
	    from   pay_element_classifications
	    where  classification_id = r_each_row.classification_id;
Line: 1669

	   	select distinct null
	   	into   l_null_return
	   	from   hr_s_formulas_f
	   	where  formula_id = r_each_row.formula_id;
Line: 1688

	        select distinct null
	        into   l_null_Return
		from   ff_formulas_f
	   	where  formula_id = r_each_row.formula_id;
Line: 1710

	   	select null
	   	into   l_null_return
	   	from   hr_s_benefit_classifications
	   	where r_each_row.benefit_classification_id=benefit_classification_id;
Line: 1729

	        select null
	        into   l_null_return
	        from   ben_benefit_classifications
	        where r_each_row.benefit_classification_id=benefit_classification_id;
Line: 1772

        select /*+ INDEX_FFS(pe) */ business_group_id
        from   pay_element_types_f pe
        where  business_group_id is not null
        and    replace(ltrim(rtrim(upper(element_name))), ' ', '_') =
               replace(ltrim(rtrim(upper(r_distinct.c_true_key))), ' ', '_');
Line: 1788

	-- tables the row is either deleted or not. If the delivered row
	-- is 'stamped' with a legislation subgroup, then a check must be
	-- made to see if that subgroup is active or not. This check only
	-- needs to be performed in phase 1, since once this decision is
	-- made, it is pointless to perform this logic again.

	-- An exception is raised if no rows are returned in this select
        -- statement. If no rows are returned then one of the following
        -- is true:
	--     1. No ownership parameters are defined.
	--     2. The products, for which owning parameters are defined, are
        --        not installed with as status of 'I'.
	--     3. The data is defined for a legislation subgroup that is not
        --        active.

        BEGIN

   	    IF p_phase = 1 THEN
               --
               --if exception raised then this row is not needed
               if (r_distinct.legislation_subgroup is null) then
               select distinct null
               into   l_null_Return
               from   dual
               where exists (
                select null
                from   hr_s_application_ownerships a
               ,      fnd_product_installations b
               ,      fnd_application c
               where  a.key_name = 'ELEMENT_TYPE_ID'
               and    a.key_value = r_distinct.c_surrogate_key
               and    a.product_name = c.application_short_name
               and    c.application_id = b.application_id
               and    ((b.status = 'I' and c.application_short_name <> 'PQP')
                       or
                       (b.status in ('I', 'S') and c.application_short_name = 'PQP')));
Line: 1825

               select distinct null
               into   l_null_Return
               from   dual
               where exists (
                select null
                from   hr_s_application_ownerships a
               ,      fnd_product_installations b
               ,      fnd_application c
               where  a.key_name = 'ELEMENT_TYPE_ID'
               and    a.key_value = r_distinct.c_surrogate_key
   	       and    a.product_name = c.application_short_name
   	       and    c.application_id = b.application_id
               and    ((b.status = 'I' and c.application_short_name <> 'PQP')
                       or
                       (b.status in ('I', 'S') and c.application_short_name = 'PQP')))
   	       and  exists
	             (select null
	              from hr_legislation_subgroups d
                      where d.legislation_code = r_distinct.legislation_code
                      and d.legislation_subgroup =
                                             r_distinct.legislation_subgroup
                      and d.active_inactive_flag = 'A'
                     );
Line: 1885

	       select distinct null
	       into   l_null_return
	       from   pay_element_types_f a
	       where  a.business_group_id is not null
	       and    replace(ltrim(rtrim(upper(a.element_name))), ' ', '_') =
                      replace(ltrim(rtrim(upper(r_distinct.c_true_key))), ' ', '_');
Line: 1912

                   select distinct null
                   into   l_null_return
                   from   per_business_groups pbg
                   where  pbg.business_group_id = elts.business_group_id
                   and    pbg.legislation_code = r_distinct.legislation_code;
Line: 1948

	       select distinct null
	       into   l_null_return
	       from   pay_element_types_f
	       where  element_name = r_distinct.c_true_key
	       and    nvl (legislation_code, 'x') <>
		      nvl (r_distinct.legislation_code, 'x')
	       and   (legislation_code is null
	      	      or r_distinct.legislation_code is null )
	       and    business_group_id is null;
Line: 1977

    PROCEDURE delete_live_children
    ------------------------------
    IS
    -- Deletes rows from a live account in readiness for them to be installed

    BEGIN

   	delete from pay_sub_classification_rules_f
   	where  element_type_id = r_distinct.c_surrogate_key
   	and    business_group_id is null;
Line: 1988

   	delete from pay_formula_result_rules_f a
   	where  a.business_group_id is null
   	and    exists
          (select null
           from   pay_status_processing_rules_f b
           where  b.status_processing_rule_id = a.status_processing_rule_id
           and    b.element_type_id = r_distinct.c_surrogate_key
	   and    b.business_group_id is null
          );
Line: 1998

   	delete from pay_status_processing_rules_f
   	where  element_type_id = r_distinct.c_surrogate_key
   	and    business_Group_id is null;
Line: 2002

   	delete from pay_element_types_f
   	where  element_type_id = r_distinct.c_surrogate_key
   	and    business_Group_id is null;
Line: 2006

    END delete_live_children;
Line: 2019

		delete from pay_input_values_f
	   	where  business_group_id is null
	   	and    input_value_id = i_values.input_value_id;
Line: 2028

                  select FLEX_VALUE_SET_ID
                  into   l_flex_value_set_id
                  from   fnd_flex_value_sets
                  where  FLEX_VALUE_SET_NAME = i_values.value_set_name;
Line: 2040

	   	insert into pay_input_values_f
	   	(input_value_id
	   	,effective_start_date
	   	,effective_end_date
	  	,element_type_id
	   	,lookup_type
	   	,business_group_id
	   	,legislation_code
	  	,formula_id
	  	,display_sequence
	   	,generate_db_items_flag
	  	,hot_default_flag
	  	,mandatory_flag
	  	,name
	   	,uom
	   	,default_value
	   	,legislation_subgroup
	   	,max_value
	   	,min_value
	   	,warning_or_error
	   	,last_update_date
	   	,last_updated_by
	   	,last_update_login
	   	,created_by
	   	,creation_date
                ,value_set_id
	   	)
	   	select input_value_id
	   	,effective_start_date
	   	,effective_end_date
	   	,element_type_id
	   	,lookup_type
	   	,business_group_id
	   	,legislation_code
	  	,formula_id
	  	,display_sequence
	   	,generate_db_items_flag
	   	,hot_default_flag
	   	,mandatory_flag
	   	,name
	   	,uom
	   	,default_value
	   	,legislation_subgroup
	   	,max_value
	   	,min_value
	   	,warning_or_error
	   	,last_update_date
	   	,last_updated_by
	   	,last_update_login
	   	,created_by
	   	,creation_date
                ,l_flex_value_set_id
	   	from hr_s_input_values_f
	   	where input_value_id = i_values.input_value_id;
Line: 2105

	   	delete from hr_s_input_values_f
	   	where  input_value_id = i_values.input_value_id;
Line: 2130

	    select distinct null
	    into   l_null_Return
	    from   hr_s_input_values_f
	    where  element_type_id = l_new_element_type_id;
Line: 2155

   	select distinct null
   	into   l_null_return
   	from   pay_element_types_f a
   	where  a.business_Group_id is null
   	and    a.element_name = p_element_name
   	and    exists
		(select null
		 from   pay_element_types_f b
	 	where  b.element_type_id <> a.element_Type_id
	 	and    b.element_name = a.element_name
	 	and    b.business_Group_id is null
	 	and    b.legislation_code = a.legislation_code
	 	and    a.effective_start_date between b.effective_start_date and
		                               b.effective_end_date
		);
Line: 2183

	-- Function to insert date effective element rows for a given element type id

    BEGIN

   	IF NOT valid_ownership THEN
	    return FALSE;
Line: 2193

	    update_uid;
Line: 2206

	    SELECT status
	    INTO   l_payroll_install_status
	    FROM   fnd_product_installations
	    WHERE  application_id = 801;
Line: 2211

	    delete_live_children;
Line: 2231

	    	insert into pay_element_types_f
	    	(element_type_id
	    	,effective_start_date
	    	,effective_end_date
	   	,business_group_id
	   	,legislation_code
	    	,input_currency_code
	    	,output_currency_code
	    	,classification_id
	    	,benefit_classification_iD
	    	,additional_entry_allowed_flag
	    	,adjustment_only_flag
	    	,closed_for_entry_flag
	    	,element_name
	    	,indirect_only_flag
	    	,multiply_value_flag
	    	,post_termination_rule
	    	,process_in_run_flag
	    	,processing_priority
	    	,processing_type
	    	,standard_link_flag
	    	,formula_id
	    	,comment_id
	    	,description
	    	,legislation_subgroup
	    	,qualifying_age
	    	,qualifying_length_of_service
	    	,qualifying_units
	    	,reporting_name
		,third_party_pay_only_flag
	    	,last_update_date
	    	,last_updated_by
	    	,last_update_login
	    	,created_by
	    	,creation_date
	    	,multiple_entries_allowed_flag
	    	,element_information_category
	   	,element_information1
	    	,element_information2
	    	,element_information3
	    	,element_information4
	    	,element_information5
	    	,element_information6
	    	,element_information7
	    	,element_information8
	    	,element_information9
	    	,element_information10
	    	,element_information11
	    	,element_information12
	    	,element_information13
	    	,element_information14
	    	,element_information15
	    	,element_information16
	    	,element_information17
	    	,element_information18
	    	,element_information19
	    	,element_information20
                ,iterative_flag
                ,iterative_formula_id
                ,iterative_priority
                ,retro_summ_ele_id
                ,grossup_flag
                ,process_mode
                ,proration_group_id
                ,proration_formula_id
                ,TIME_DEFINITION_TYPE
                ,TIME_DEFINITION_ID
	    	)
	   	values
	    	(each_row.element_type_id
	    	,each_row.effective_start_date
	   	,each_row.effective_end_date
	    	,each_row.business_group_id
	    	,each_row.legislation_code
	    	,each_row.input_currency_code
	    	,each_row.output_currency_code
	    	,each_row.classification_id
	    	,each_row.benefit_classification_iD
	    	,each_row.additional_entry_allowed_flag
	    	,each_row.adjustment_only_flag
	    	,each_row.closed_for_entry_flag
	    	,each_row.element_name
	    	,each_row.indirect_only_flag
	    	,each_row.multiply_value_flag
	    	,each_row.post_termination_rule
	    	,each_row.process_in_run_flag
	    	,each_row.processing_priority
	    	,each_row.processing_type
	    	,each_row.standard_link_flag
	    	,l_formula_id
	    	,each_row.comment_id
	    	,each_row.description
	    	,each_row.legislation_subgroup
	    	,each_row.qualifying_age
	    	,each_row.qualifying_length_of_service
	    	,each_row.qualifying_units
	    	,each_row.reporting_name
	    	,each_row.third_party_pay_only_flag
	    	,each_row.last_update_date
	    	,each_row.last_updated_by
	    	,each_row.last_update_login
	    	,each_row.created_by
	    	,each_row.creation_date
	    	,each_row.multiple_entries_allowed_flag
	    	,each_row.element_information_category
	    	,each_row.element_information1
	    	,each_row.element_information2
	    	,each_row.element_information3
	    	,each_row.element_information4
	    	,each_row.element_information5
	    	,each_row.element_information6
	    	,each_row.element_information7
	    	,each_row.element_information8
	    	,each_row.element_information9
	    	,each_row.element_information10
	    	,each_row.element_information11
	    	,each_row.element_information12
	    	,each_row.element_information13
	    	,each_row.element_information14
	    	,each_row.element_information15
	    	,each_row.element_information16
	    	,each_row.element_information17
	    	,each_row.element_information18
	    	,each_row.element_information19
	    	,each_row.element_information20
                ,each_row.iterative_flag
                ,each_row.iterative_formula_id
                ,each_row.iterative_priority
                ,each_row.retro_summ_ele_id
                ,each_row.grossup_flag
                ,each_row.process_mode
                ,each_row.proration_group_id
                ,each_row.proration_formula_id
                ,each_row.TIME_DEFINITION_TYPE
                ,each_row.TIME_DEFINITION_ID
	    	);
Line: 2392

		    select null
		    into   l_null_return
		    from   pay_element_classifications
		    where  classification_id = s_rules.classification_id;
Line: 2398

                    insert into pay_sub_classification_rules_f
		    (sub_classification_rule_id
		    ,effective_start_date
		    ,effective_end_date
		    ,element_type_id
		    ,classification_id
		    ,business_group_id
		    ,legislation_code
		    ,last_update_date
		    ,last_updated_by
		    ,last_update_login
		    ,created_by
		    ,creation_date
		    )
		    values
		    (s_rules.sub_classification_rule_id
		    ,s_rules.effective_start_date
		    ,s_rules.effective_end_date
		    ,s_rules.element_type_id
		    ,s_rules.classification_id
		    ,s_rules.business_group_id
		    ,s_rules.legislation_code
		    ,s_rules.last_update_date
		    ,s_rules.last_updated_by
		    ,s_rules.last_update_login
		    ,s_rules.created_by
		    ,s_rules.creation_date
		    );
Line: 2473

		   	insert into pay_status_processing_rules_f
		  	 (STATUS_PROCESSING_RULE_ID
		   	,EFFECTIVE_START_DATE
		  	,EFFECTIVE_END_DATE
		   	,BUSINESS_GROUP_ID
		   	,LEGISLATION_CODE
		   	,ELEMENT_TYPE_ID
		   	,ASSIGNMENT_STATUS_TYPE_ID
		   	,FORMULA_ID
		   	,PROCESSING_RULE
		   	,COMMENT_ID
		   	,LEGISLATION_SUBGROUP
		   	,LAST_UPDATE_DATE
		   	,LAST_UPDATED_BY
		   	,LAST_UPDATE_LOGIN
		   	,CREATED_BY
		   	,CREATION_DATE
		   	)
		   	values
		   	(all_rules.STATUS_PROCESSING_RULE_ID
		   	,all_rules.EFFECTIVE_START_DATE
		   	,all_rules.EFFECTIVE_END_DATE
		   	,all_rules.BUSINESS_GROUP_ID
		   	,all_rules.LEGISLATION_CODE
		   	,all_rules.ELEMENT_TYPE_ID
		   	,all_rules.ASSIGNMENT_STATUS_TYPE_ID
		   	,all_rules.FORMULA_ID
		   	,all_rules.PROCESSING_RULE
		   	,all_rules.COMMENT_ID
		   	,all_rules.LEGISLATION_SUBGROUP
		   	,all_rules.LAST_UPDATE_DATE
		   	,all_rules.LAST_UPDATED_BY
		   	,all_rules.LAST_UPDATE_LOGIN
		   	,all_rules.CREATED_BY
		   	,all_rules.CREATION_DATE
		   	);
Line: 2532

		   	insert into pay_formula_result_rules_f
		   	(FORMULA_RESULT_RULE_ID
		   	,EFFECTIVE_START_DATE
		   	,EFFECTIVE_END_DATE
		   	,BUSINESS_GROUP_ID
		   	,LEGISLATION_CODE
		   	,STATUS_PROCESSING_RULE_ID
		   	,RESULT_NAME
		  	 ,RESULT_RULE_TYPE
		  	 ,LEGISLATION_SUBGROUP
		  	 ,SEVERITY_LEVEL
		  	 ,INPUT_VALUE_ID
		  	 ,ELEMENT_TYPE_ID
		  	 ,LAST_UPDATE_DATE
		   	,LAST_UPDATED_BY
		   	,LAST_UPDATE_LOGIN
		   	,CREATED_BY
		   	,CREATION_DATE
		   	)
		   	values
		   	(all_frrs.FORMULA_RESULT_RULE_ID
		   	,all_frrs.EFFECTIVE_START_DATE
		   	,all_frrs.EFFECTIVE_END_DATE
		   	,all_frrs.BUSINESS_GROUP_ID
		   	,all_frrs.LEGISLATION_CODE
		   	,all_frrs.STATUS_PROCESSING_RULE_ID
		   	,all_frrs.RESULT_NAME
		   	,all_frrs.RESULT_RULE_TYPE
		   	,all_frrs.LEGISLATION_SUBGROUP
		   	,all_frrs.SEVERITY_LEVEL
		   	,all_frrs.INPUT_VALUE_ID
		   	,all_frrs.ELEMENT_TYPE_ID
		   	,all_frrs.LAST_UPDATE_DATE
		   	,all_frrs.LAST_UPDATED_BY
		   	,all_frrs.LAST_UPDATE_LOGIN
		   	,all_frrs.CREATED_BY
		   	,all_frrs.CREATION_DATE
		  	 );
Line: 2676

    l_null_return varchar2(1);		-- For 'select null' statements
Line: 2679

    CURSOR stu				-- Selects all rows from startup entity
    IS
	select element_set_name c_true_key
	,      element_set_id c_surrogate_key
	,      legislation_code c_leg_code
	,      element_set_type
	,      last_update_date
	,      last_updated_by
	,      last_update_login
	,      created_by
	,      creation_date
	,      rowid
	from   hr_s_element_sets;
Line: 2697

	select *
	from   hr_s_element_type_rules
	where  element_set_id = ele_set_id;
Line: 2705

	select *
	from   hr_s_ele_classn_rules
	where  element_set_id = ele_set_id;
Line: 2723

	-- 1. Where the newly select sequence value conflicts with values
	--    in the STU tables.
	-- 2. Where selected surrogate keys, from the installed tables,
	--    conflict with other rows in the STU tables.
	--
	-- Both of the above scenario's are tested for.
	-- The first is a simple match, where if a value is detected in the
	-- STU tables and the installed tables then a conflict is detected. In
	-- This instance all STU surrogate keys, for this table, are updated.
	-- The second is tested for using the sequences.
	-- If the next value from the live sequence is within the range of
	-- delivered surrogate id's then the live sequence must be incremented.
	-- If no action is taken, then duplicates may be introduced into the
	-- delivered tables, and child rows may be totally invalidated.

    BEGIN


	BEGIN	--check that the installed id's will not conflict
		--with the delivered values


	    select distinct null
	    into   l_null_return
	    from   pay_element_sets a
	    where  exists
		(select null
		 from   hr_s_element_sets b
		 where  a.element_set_id = b.element_set_id
		);
Line: 2755

	    --update all element_set_id's to remove conflict

	    update /*+NO_INDEX*/ hr_s_element_sets
	    set    element_set_id = element_set_id - 50000000;
Line: 2760

            update /*+NO_INDEX*/ hr_s_element_type_rules
            set    element_set_id = element_set_id - 50000000;
Line: 2763

            update /*+NO_INDEX*/ hr_s_ele_classn_rules
            set    element_set_id = element_set_id - 50000000;
Line: 2766

	    update hr_s_application_ownerships
	    set    key_value = key_value - 50000000
	    where  key_name = 'ELEMENT_SET_ID';
Line: 2776

	select min(element_set_id) - (count(*) *3)
	,      max(element_set_id) + (count(*) *3)
	into   v_min_delivered
	,      v_max_delivered
	from   hr_s_element_sets;
Line: 2782

	select pay_element_sets_s.nextval
	into   v_sequence_number
	from   dual;
Line: 2815

	hr_legislation.insert_hr_stu_exceptions('pay_element_sets'
        ,      stu_rec.c_surrogate_key
        ,      exception_type
        ,      stu_rec.c_true_key);
Line: 2823

    PROCEDURE update_uid
    --------------------
    IS
	-- Subprogram to update surrogate UID and all occurrences in child rows

    BEGIN

	BEGIN

	    select distinct element_set_id
	    into   l_new_surrogate_key
	    from   pay_element_sets
	    where  element_set_name = stu_rec.c_true_key
	    and    business_group_id is null
            and  ( (legislation_code is null
                 and  stu_rec.c_leg_code is null)
                 or (legislation_code = stu_rec.c_leg_code) );
Line: 2844

	   select pay_element_sets_s.nextval
	   into   l_new_surrogate_key
	   from   dual;
Line: 2860

	--update all child entities
   	update hr_s_element_sets
   	set    element_set_id = l_new_surrogate_key
   	where  element_set_id = stu_rec.c_surrogate_key;
Line: 2865

   	update hr_s_application_ownerships
   	set    key_value = to_char(l_new_surrogate_key)
   	where  key_value = to_char(stu_rec.c_surrogate_key)
   	and    key_name = 'ELEMENT_SET_ID';
Line: 2870

   	update hr_s_element_type_rules
   	set    element_set_id = l_new_surrogate_key
   	where  element_set_id = stu_rec.c_surrogate_key;
Line: 2874

   	update hr_s_ele_classn_rules
   	set    element_set_id = l_new_surrogate_key
   	where  element_set_id = stu_rec.c_surrogate_key;
Line: 2878

    END update_uid;
Line: 2889

   	delete from hr_s_element_type_rules
   	where  element_set_id = l_new_surrogate_key;
Line: 2892

   	delete from hr_s_ele_classn_rules
   	where  element_set_id = l_new_surrogate_key;
Line: 2895

   	delete from hr_s_element_sets
   	where  rowid = stu_rec.rowid;
Line: 2912

	-- then this row is not required and may be deleted from the delivery
	-- tables.

	-- If legislation code and subgroup code are included on the delivery
	-- tables, a check must be made to determine if the data is defined for
	-- a specific subgroup. If so the subgroup must be 'A'ctive for this
	-- installation.

	-- A return code of TRUE indicates that thhe row is required.

	-- The exception is raised within this procedure if no rows are returned
	-- in this select statement. If no rows are returned then one of the
	-- following is true:
	--     1. No ownership parameters are defined.
	--     2. The products, for which owning parameters are defined, are not
	--        installed with as status of 'I'.
	--     3. The data is defined for a legislation subgroup that is not active.

	IF p_phase <> 1 THEN	-- Only perform in phase 1
		return TRUE;
Line: 2935

	select null --if exception raised then this row is not needed
	into   l_null_return
	from   dual
	where  exists
	(select null
	from   hr_s_application_ownerships a
	,      fnd_product_installations b
	,      fnd_application c
	where  a.key_name = 'ELEMENT_SET_ID'
	and    a.key_value = stu_rec.c_surrogate_key
	and    a.product_name = c.application_short_name
	and    c.application_id = b.application_id
        and    ((b.status = 'I' and c.application_short_name <> 'PQP')
                or
                (b.status in ('I', 'S') and c.application_short_name = 'PQP')));
Line: 2968

	-- Check if a delivered row is needed and insert into the
	-- live tables if it is

	v_inst_update date;	-- Holds update details of installed row
Line: 2984

            select distinct null
            into   l_null_return
            from pay_element_sets a
            where a.element_set_name = stu_rec.c_true_key
            and   a.business_group_id is not null
            and   exists (select null from per_business_groups b
              where b.business_group_id = a.business_group_id
              and b.legislation_code = nvl(stu_rec.c_leg_code,b.legislation_code));
Line: 3017

            select distinct null
            into   l_null_return
            from   pay_element_sets
            where  element_set_name = stu_rec.c_true_key
            and    nvl(legislation_code,'x') <> nvl(stu_rec.c_leg_code,'x')
            and   (legislation_code is null
                  or stu_rec.c_leg_code is null )
	    and    business_group_id is null;
Line: 3044

	-- If the procedure is called in phase 2, then the live row is updated
	-- with the values on the delivered row.

	-- The routine check_parents validates foreign key references and
	-- ensures referential integrity. The routine checks to see if the
	-- parents of a given row have been transfered to the live tables.

	-- This may only be called in phase two since in phase one all
	-- parent rows will remain in the delivery tables.

	-- After the above checks only data that has been chanegd or is new
	-- will be left in the delivery tables. At this stage if the row is
	-- already present then it must be updated to ensure referential
	-- integrity. Therefore an update will be performed and if SQL%FOUND
	-- is FALSE an insert will be performed.

	-- The last step of the transfer, in phase 2, is to delete the now
	-- transfered row from the delivery tables.

   	IF p_phase = 1 THEN
	    return;
Line: 3067

   	delete from pay_element_type_rules
   	where  element_set_id = l_new_surrogate_key;
Line: 3070

   	delete from pay_ele_classification_rules
   	where  element_set_id = l_new_surrogate_key;
Line: 3073

   	update pay_element_sets
   	set    element_set_type = stu_rec.element_set_type
   	,      last_update_date = stu_rec.last_update_date
   	,      last_updated_by = stu_rec.last_updated_by
   	,      last_update_login = stu_rec.last_update_login
   	,      created_by = stu_rec.created_by
   	,      creation_date = stu_rec.creation_date
   	where  element_set_id = stu_rec.c_surrogate_key;
Line: 3086

	    insert into pay_element_sets
	    (element_set_name
	    ,element_set_id
	    ,legislation_code
	    ,element_set_type
	    ,last_update_date
	    ,last_updated_by
	    ,last_update_login
	    ,created_by
	    ,creation_date
	    )
	    values
	    (stu_rec.c_true_key
	    ,stu_rec.c_surrogate_key
	    ,stu_rec.c_leg_code
	    ,stu_rec.element_set_type
	    ,stu_rec.last_update_date
	    ,stu_rec.last_updated_by
	    ,stu_rec.last_update_login
	    ,stu_rec.created_by
	    ,stu_rec.creation_date
	    );
Line: 3133

	   	select null
	   	into   l_null_return
	   	from   pay_element_types_f
	   	where  element_type_id = ele_types.element_type_id;
Line: 3139

	   	insert into pay_element_type_rules
	   	(element_type_id
	   	,element_set_id
	   	,include_or_exclude
	   	,last_update_date
	   	,last_updated_by
	   	,last_update_login
	   	,created_by
	   	,creation_date)
	   	values
           	(ele_types.element_Type_id
           	,ele_types.element_Set_id
           	,ele_types.include_or_exclude
           	,ele_types.last_update_date
           	,ele_types.last_updated_by
           	,ele_types.last_update_login
           	,ele_types.created_by
           	,ele_types.creation_date);
Line: 3187

	    	select null
	    	into   l_null_return
	    	from   pay_element_classifications
	    	where  classification_id = ele_class.classification_id;
Line: 3193

	    	insert into pay_ele_classification_rules
	    	(element_set_id
	    	,classification_id
	    	,last_update_date
	    	,last_updated_by
	    	,last_update_login
	    	,created_by
	    	,creation_date)
	    	values
            	(ele_class.element_set_id
            	,ele_class.classification_id
            	,ele_class.last_update_date
            	,ele_class.last_updated_by
            	,ele_class.last_update_login
            	,ele_class.created_by
            	,ele_class.creation_date);
Line: 3270

		update_uid;
Line: 3291

    l_null_return varchar2(1);		-- For 'select null' statements
Line: 3294

    CURSOR stu				-- Selects all rows from startup entity
    IS
	select user_table_id c_surrogate_key
	,      business_group_id
	,      legislation_code c_leg_code
	,      range_or_match
	,      user_key_units
	,      user_table_name c_true_key
	,      legislation_subgroup c_leg_sgrp
	,      last_update_date
	,      last_updated_by
	,      last_update_login
	,      created_by
	,      creation_date
	,      rowid
	,      user_row_title
	from   hr_s_user_tables;
Line: 3324

	-- 1. Where the newly select sequence value conflicts with values
	--    in the STU tables.
	-- 2. Where selected surrogate keys, from the installed tables,
	--    conflict with other rows in the STU tables.
	--
	-- Both of the above scenario's are tested for.
	-- The first is a simple match, where if a value is detected in the
	-- STU tables and the installed tables then a conflict is detected. In
	-- This instance all STU surrogate keys, for this table, are updated.
	-- The second is tested for using the sequences.
	-- If the next value from the live sequence is within the range of
	-- delivered surrogate id's then the live sequence must be incremented.
	-- If no action is taken, then duplicates may be introduced into the
	-- delivered tables, and child rows may be totally invalidated.

    BEGIN


	BEGIN	--check that the installed id's will not conflict
		--with the delivered values


	    select distinct null
	    into   l_null_return
	    from   pay_user_tables a
	    where  exists
		(select null
		 from   hr_s_user_tables b
		 where  a.user_table_id = b.user_table_id
		);
Line: 3356

	    --update all user_table_id's to remove conflict

	    update /*+NO_INDEX*/ hr_s_user_columns
	    set    user_table_id = user_table_id - 50000000;
Line: 3361

            update /*+NO_INDEX*/ hr_s_user_rows_f
            set    user_table_id = user_table_id - 50000000;
Line: 3364

            update /*+NO_INDEX*/ hr_s_user_tables
            set    user_table_id = user_table_id - 50000000;
Line: 3367

	    update hr_s_application_ownerships
	    set    key_value = key_value - 50000000
	    where  key_name = 'USER_TABLE_ID';
Line: 3377

	select min(user_table_id) - (count(*) *3)
	,      max(user_table_id) + (count(*) *3)
	into   v_min_delivered
	,      v_max_delivered
	from   hr_s_user_tables;
Line: 3383

	select pay_user_tables_s.nextval
	into   v_sequence_number
	from   dual;
Line: 3416

	hr_legislation.insert_hr_stu_exceptions('pay_user_tables'
        ,      stu_rec.c_surrogate_key
        ,      exception_type
        ,      stu_rec.c_true_key);
Line: 3424

    PROCEDURE update_uid
    --------------------
    IS
	-- Subprogram to update surrogate UID and all occurrences in child rows

    BEGIN


	BEGIN

	    select distinct user_table_id
	    into   l_new_surrogate_key
	    from   pay_user_tables
	    where  user_table_name = stu_rec.c_true_key
	    and    business_group_id is null
            and  ( (legislation_code is null
                 and  stu_rec.c_leg_code is null)
                 or (legislation_code = stu_rec.c_leg_code) );
Line: 3446

	    select pay_user_tables_s.nextval
	    into   l_new_surrogate_key
	    from   dual;
Line: 3462

	-- Update all child entities
   	update hr_s_user_tables
   	set    user_table_id = l_new_surrogate_key
   	where  user_table_id = stu_rec.c_surrogate_key;
Line: 3467

   	update hr_s_application_ownerships
   	set    key_value = to_char(l_new_surrogate_key)
   	where  key_value = to_char(stu_rec.c_surrogate_key)
   	and    key_name = 'USER_TABLE_ID';
Line: 3472

   	update hr_s_user_columns
   	set    user_table_id = l_new_surrogate_key
   	where  user_table_id = stu_rec.c_surrogate_key;
Line: 3476

   	update hr_s_user_rows_f
   	set    user_table_id = l_new_surrogate_key
   	where  user_table_id = stu_rec.c_surrogate_key;
Line: 3480

    END update_uid;
Line: 3489

   	delete from hr_s_user_tables
   	where  rowid = stu_rec.rowid;
Line: 3505

	-- then this row is not required and may be deleted from the delivery
	-- tables.

	-- If legislation code and subgroup code are included on the delivery
	-- tables, a check must be made to determine if the data is defined for
	-- a specific subgroup. If so the subgroup must be 'A'ctive for this
	-- installation.

	-- A return code of TRUE indicates that thhe row is required.

	-- The exception is raised within this procedure if no rows are returned
	-- in this select statement. If no rows are returned then one of the
	-- following is true:
	--     1. No ownership parameters are defined.
	--     2. The products, for which owning parameters are defined, are not
	--        installed with as status of 'I'.
	--     3. The data is defined for a legislation subgroup that is not active.

	IF p_phase <> 1 THEN	-- Only perform in phase 1
	    return TRUE;
Line: 3530

        select null
        into   l_null_return
        from   dual
        where  exists
        (select null
        from   hr_s_application_ownerships a
        ,      fnd_product_installations b
        ,      fnd_application c
        where  a.key_name = 'USER_TABLE_ID'
        and    a.key_value = stu_rec.c_surrogate_key
        and    a.product_name = c.application_short_name
        and    c.application_id = b.application_id
        and    ((b.status = 'I' and c.application_short_name <> 'PQP')
                or
                (b.status in ('I', 'S') and c.application_short_name = 'PQP')));
Line: 3546

	select null
	into   l_null_return
	from   dual
	where  exists
	(select null
	from   hr_s_application_ownerships a
	,      fnd_product_installations b
	,      fnd_application c
	where  a.key_name = 'USER_TABLE_ID'
	and    a.key_value = stu_rec.c_surrogate_key
	and    a.product_name = c.application_short_name
	and    c.application_id = b.application_id
        and    ((b.status = 'I' and c.application_short_name <> 'PQP')
                or
                (b.status in ('I', 'S') and c.application_short_name = 'PQP')))
	and  exists (select null from hr_legislation_subgroups d
	      where  d.legislation_code = stu_rec.c_leg_code
	     and  d.legislation_subgroup = stu_rec.c_leg_sgrp
	     and  d.active_inactive_flag = 'A'
	         );
Line: 3586

	-- Check if a delivered row is needed and insert into the
	-- live tables if it is

    v_inst_update date;		-- Holds update details of installed row
Line: 3602

            select distinct null
            into   l_null_return
            from pay_user_tables a
            where a.user_table_name = stu_rec.c_true_key
            and   a.business_group_id is not null
            and   exists (select null from per_business_groups b
              where b.business_group_id = a.business_group_id
              and b.legislation_code = nvl(stu_rec.c_leg_code,b.legislation_code));
Line: 3634

            select distinct null
            into   l_null_return
            from   pay_user_tables
            where  user_table_name = stu_rec.c_true_key
            and    nvl(legislation_code,'x') <> nvl(stu_rec.c_leg_code,'x')
            and   (legislation_code is null or stu_rec.c_leg_code is null )
	    and    business_group_id is null;
Line: 3658

	-- If the procedure is called in phase 2, then the live row is updated
	-- with the values on the delivered row.

	-- The routine check_parents validates foreign key references and
	-- ensures referential integrity. The routine checks to see if the
	-- parents of a given row have been transfered to the live tables.

	-- This may only be called in phase two since in phase one all
	-- parent rows will remain in the delivery tables.

	-- After the above checks only data that has been chanegd or is new
	-- will be left in the delivery tables. At this stage if the row is
	-- already present then it must be updated to ensure referential
	-- integrity. Therefore an update will be performed and if SQL%FOUND
	-- is FALSE an insert will be performed.

	-- The last step of the transfer, in phase 2, is to delete the now
	-- transfered row from the delivery tables.

   	IF p_phase = 1 THEN
	    return;
Line: 3682

   	update pay_user_tables
   	set range_or_match = stu_rec.range_or_match
   	,   user_key_units = stu_rec.user_key_units
   	,   last_update_date = stu_rec.last_update_date
   	,   last_updated_by = stu_rec.last_updated_by
   	,   last_update_login = stu_rec.last_update_login
   	,   created_by = stu_rec.created_by
   	,   creation_date = stu_rec.creation_date
   	,   user_row_title = stu_rec.user_row_title
   	where  user_table_id = stu_rec.c_surrogate_key;
Line: 3696

	    insert into pay_user_tables
	    (user_table_id
	    ,business_group_id
	    ,legislation_code
	    ,range_or_match
	    ,user_key_units
	    ,user_table_name
	    ,legislation_subgroup
	    ,last_update_date
	    ,last_updated_by
	    ,last_update_login
	    ,created_by
	    ,creation_date
	    ,user_row_title
	    )
	    values
	    (stu_rec.c_surrogate_key
	    ,stu_rec.business_group_id
	    ,stu_rec.c_leg_code
	    ,stu_rec.range_or_match
	    ,stu_rec.user_key_units
	    ,stu_rec.c_true_key
	    ,stu_rec.c_leg_sgrp
	    ,stu_rec.last_update_date
	    ,stu_rec.last_updated_by
	    ,stu_rec.last_update_login
	    ,stu_rec.created_by
	    ,stu_rec.creation_date
	    ,stu_rec.user_row_title
	    );
Line: 3781

	        update_uid;
Line: 3802

    l_null_return varchar2(1);		-- For 'select null' statements
Line: 3806

    CURSOR stu				-- Selects all rows from startup entity
    IS
	--
	-- #271139 - note that the user column name is not the true key on
	-- its own; it's only unique for the user table.
Line: 3811

	-- Must use the user table id in select criteria for the true key.
	--
	select user_column_id c_surrogate_key
	,      business_group_id
	,      legislation_code c_leg_code
	,      user_table_id
	,      formula_id
	,      user_column_name c_true_key
	,      legislation_subgroup c_leg_sgrp
	,      last_update_date
	,      last_updated_by
	,      last_update_login
	,      created_by
	,      creation_date
	,      rowid
	from   hr_s_user_columns;
Line: 3840

	-- 1. Where the newly select sequence value conflicts with values
	--    in the STU tables.
	-- 2. Where selected surrogate keys, from the installed tables,
	--    conflict with other rows in the STU tables.
	--
	-- Both of the above scenario's are tested for.
	-- The first is a simple match, where if a value is detected in the
	-- STU tables and the installed tables then a conflict is detected. In
	-- This instance all STU surrogate keys, for this table, are updated.
	-- The second is tested for using the sequences.
	-- If the next value from the live sequence is within the range of
	-- delivered surrogate id's then the live sequence must be incremented.
	-- If no action is taken, then duplicates may be introduced into the
	-- delivered tables, and child rows may be totally invalidated.

    BEGIN


	BEGIN	--check that the installed id's will not conflict
		--with the delivered values


	    select distinct null
	    into   l_null_return
	    from   pay_user_columns a
	    where  exists
		(select null
		 from   hr_s_user_columns b
		 where  a.user_column_id = b.user_column_id
		);
Line: 3872

	    --update all user_column_id's to remove conflict

	    update /*+NO_INDEX*/ hr_s_user_columns
	    set    user_column_id = user_column_id - 50000000;
Line: 3877

            update /*+NO_INDEX*/ hr_s_user_column_instances_f
            set    user_column_id = user_column_id - 50000000;
Line: 3880

	    update hr_s_application_ownerships
	    set    key_value = key_value - 50000000
	    where  key_name = 'USER_COLUMN_ID';
Line: 3890

	select min(user_column_id) - (count(*) *3)
	,      max(user_column_id) + (count(*) *3)
	into   v_min_delivered
	,      v_max_delivered
	from   hr_s_user_columns;
Line: 3896

	select pay_user_columns_s.nextval
	into   v_sequence_number
	from   dual;
Line: 3929

	hr_legislation.insert_hr_stu_exceptions('pay_user_columns'
        ,      stu_rec.c_surrogate_key
        ,      exception_type
        ,      stu_rec.c_true_key);
Line: 3937

    PROCEDURE update_uid
    --------------------
    IS
    	-- subprogram to update surrogate UID and all occurrences in child rows

    BEGIN


	BEGIN
	   --
	   -- #271139 - hitting a problem because the user column name is
	   -- not the true key on its own; it's only unique for the user table.
Line: 3949

	   -- Add the user table id to the select criteria.
	   --
	    select distinct user_column_id
	    into   l_new_surrogate_key
	    from   pay_user_columns
	    where  user_column_name = stu_rec.c_true_key
	    and    user_table_id    = stu_rec.user_table_id
	    and    business_group_id is null
            and  ( (legislation_code is null
                 and  stu_rec.c_leg_code is null)
                 or (legislation_code = stu_rec.c_leg_code) );
Line: 3964

	    select pay_user_columns_s.nextval
	    into   l_new_surrogate_key
	    from   dual;
Line: 3981

	-- Update all child entities

   	update hr_s_user_columns
   	set    user_column_id = l_new_surrogate_key
   	where  user_column_id = stu_rec.c_surrogate_key;
Line: 3987

   	update hr_s_application_ownerships
   	set    key_value = to_char(l_new_surrogate_key)
   	where  key_value = to_char(stu_rec.c_surrogate_key)
   	and    key_name = 'USER_COLUMN_ID';
Line: 3992

   	update hr_s_user_column_instances_f
   	set    user_column_id = l_new_surrogate_key
   	where  user_column_id = stu_rec.c_surrogate_key;
Line: 3996

    END update_uid;
Line: 4005

   	delete from hr_s_user_columns
   	where  rowid = stu_rec.rowid;
Line: 4020

	-- then this row is not required and may be deleted from the delivery
	-- tables.

	-- If legislation code and subgroup code are included on the delivery
	-- tables, a check must be made to determine if the data is defined for
	-- a specific subgroup. If so the subgroup must be 'A'ctive for this
	-- installation.

	-- A return code of TRUE indicates that the row is required.

	-- The exception is raised within this procedure if no rows are returned
	-- in this select statement. If no rows are returned then one of the
	-- following is true:
	--     1. No ownership parameters are defined.
	--     2. The products, for which owning parameters are defined, are not
	--        installed with as status of 'I'.
	--     3. The data is defined for a legislation subgroup that is not active.

    BEGIN


	IF p_phase <> 1 THEN
	    return TRUE;
Line: 4048

        select null
        into   l_null_return
        from   dual
        where  exists
        (select null
        from   hr_s_application_ownerships a
        ,      fnd_product_installations b
        ,      fnd_application c
        where  a.key_name = 'USER_COLUMN_ID'
        and    a.key_value = stu_rec.c_surrogate_key
        and    a.product_name = c.application_short_name
        and    c.application_id = b.application_id
        and    ((b.status = 'I' and c.application_short_name <> 'PQP')
                or
                (b.status in ('I', 'S') and c.application_short_name = 'PQP')));
Line: 4064

	select null
	into   l_null_return
	from   dual
	where  exists
	(select null
	from   hr_s_application_ownerships a
	,      fnd_product_installations b
	,      fnd_application c
	where  a.key_name = 'USER_COLUMN_ID'
	and    a.key_value = stu_rec.c_surrogate_key
	and    a.product_name = c.application_short_name
	and    c.application_id = b.application_id
        and    ((b.status = 'I' and c.application_short_name <> 'PQP')
                or
                (b.status in ('I', 'S') and c.application_short_name = 'PQP')))
	and  exists (select null from hr_legislation_subgroups d
            where d.legislation_code = stu_rec.c_leg_code
	     and  d.legislation_subgroup = stu_rec.c_leg_sgrp
	     and  d.active_inactive_flag = 'A'
	         );
Line: 4110

	-- every foriegn key. The first select from the delivery tables.

	-- If a row is founnd then the installation of the parent must have
	-- failed, and this installation must not go ahead. If no data is
	-- found, ie: an exception is raised, the installation is valid.

	-- The second check looks for a row in the live tables. If no rows
	-- are returned then this installation is invalid, since this means
	-- that the parent referenced by this row is not present in the
	-- live tables.

	-- The distinct is used in case the parent is date effective and many rows
	-- may be returned by the same parent id.

	-- Start with checking the parent PAY_USER_TABLES


   	BEGIN

	    -- Check the tables in the delivery account

	    select distinct null
	    into   l_null_return
	    from   hr_s_user_tables
	    where  user_table_id = stu_rec.user_table_id;
Line: 4153

	    select null
	    into   l_null_return
	    from   pay_user_tables
	    where  user_table_id = stu_rec.user_table_id;
Line: 4181

	    select distinct null
	    into   l_null_return
	    from   hr_s_formulas_f
	    where  formula_id = stu_rec.formula_id;
Line: 4202

	    select null
	    into   l_null_return
	    from   ff_Formulas_f
	    where  formula_id = stu_rec.formula_id;
Line: 4224

	-- Check if a delivered row is needed and insert into the
	-- live tables if it is

        v_inst_update date;	-- Holds update details of installed row
Line: 4242

	   -- Add the user table id to the select criteria.
	   --
                select distinct null
                into   l_null_return
                from pay_user_columns a
                where a.user_table_id = stu_rec.user_table_id
                and    a.user_column_name = stu_rec.c_true_key
                and   a.business_group_id is not null
                and   exists (select null from per_business_groups b
                  where b.business_group_id = a.business_group_id
                  and b.legislation_code = nvl(stu_rec.c_leg_code,b.legislation_code));
Line: 4279

	   -- Add the user table id to the select criteria.
	   --
   	    BEGIN
        	select distinct null
        	into   l_null_return
        	from   pay_user_columns
        	where  user_column_name = stu_rec.c_true_key
	        and    user_table_id    = stu_rec.user_table_id
        	and    nvl(legislation_code,'X') <> nvl(stu_rec.c_leg_code,'X')
        	and   (legislation_code is null or stu_rec.c_leg_code is null )
		and    business_group_id is null;
Line: 4309

	    -- If the procedure is called in phase 2, then the live row is updated
	    -- with the values on the delivered row.

	    -- The routine check_parents validates foreign key references and
	    -- ensures referential integrity. The routine checks to see if the
	    -- parents of a given row have been transfered to the live tables.

	    -- This may only be called in phase two since in phase one all
	    -- parent rows will remain in the delivery tables.

	    -- After the above checks only data that has been chanegd or is new
	    -- will be left in the delivery tables. At this stage if the row is
	    -- already present then it must be updated to ensure referential
	    -- integrity. Therefore an update will be performed and if SQL%FOUND
	    -- is FALSE an insert will be performed.

	    -- The last step of the transfer, in phase 2, is to delete the now
	    -- transfered row from the delivery tables.

   	    IF p_phase = 1 THEN
 		return;
Line: 4337

   	    update pay_user_columns
   	    set formula_id = stu_rec.formula_id
   	    ,   last_update_date = stu_rec.last_update_date
   	    ,   last_updated_by = stu_rec.last_updated_by
   	    ,   last_update_login = stu_rec.last_update_login
   	    ,   created_by = stu_rec.created_by
   	    ,   creation_date = stu_rec.creation_date
   	    where  user_column_id = stu_rec.c_surrogate_key;
Line: 4349

	    insert into pay_user_columns
	    (user_column_id
	    ,business_group_id
	    ,legislation_code
	    ,user_table_id
	    ,formula_id
	    ,user_column_name
	    ,legislation_subgroup
	    ,last_update_date
	    ,last_updated_by
	    ,last_update_login
	    ,created_by
	    ,creation_date
	    )
	    values
	    (stu_rec.c_surrogate_key
	    ,stu_rec.business_group_id
	    ,stu_rec.c_leg_code
	    ,stu_rec.user_table_id
	    ,stu_rec.formula_id
	    ,stu_rec.c_true_key
	    ,stu_rec.c_leg_sgrp
	    ,stu_rec.last_update_date
	    ,stu_rec.last_updated_by
	    ,stu_rec.last_update_login
	    ,stu_rec.created_by
	    ,stu_rec.creation_date
	    );
Line: 4432

		update_uid;