DBA Data[Home] [Help]

APPS.HR_LEGISLATION SQL Statements

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

Line: 408

PROCEDURE insert_hr_stu_exceptions (p_table_name varchar2,
                                   p_surrogate_id number,
                                   p_text varchar2,
                                   p_true_key varchar2)
IS
 PRAGMA AUTONOMOUS_TRANSACTION;
Line: 416

        insert into HR_STU_EXCEPTIONS
            (table_name
            ,surrogate_id
            ,exception_text
            ,true_key)
	select
	    upper(p_table_name)
            ,p_surrogate_id
            ,p_text
            ,p_true_key
	from dual
            where not exists
                (select null
			 from   hr_stu_exceptions
			 where  p_surrogate_id = surrogate_id
			 and    table_name = upper(p_table_name));
Line: 434

END insert_hr_stu_exceptions;
Line: 456

    select increment_by
    from   all_sequences
    where  sequence_name = p_seq_name
    and    sequence_owner = l_per_owner;
Line: 469

 SELECT COUNT(*)
 INTO l_seq_managed
 FROM hr_dm_databases;
Line: 494

    l_sql_stmt := 'SELECT ' || l_per_owner || '.' || p_seq_name || '.NEXTVAL FROM DUAL';
Line: 521

INSERT INTO hr_application_ownerships
(key_name
,product_name
,key_value)
SELECT distinct ao.key_name
      ,ao.product_name
      ,ao.key_value
FROM   hr_s_application_ownerships   ao
      ,pay_element_classifications pec
WHERE  pec.legislation_code     = 'ZZ'
  AND  ao.key_name             = 'CLASSIFICATION_ID'
  AND  TO_NUMBER(ao.key_value) = pec.classification_id
  AND  NOT EXISTS (SELECT null
                   FROM   hr_application_ownerships ao2
                   WHERE  ao2.key_name     = ao.key_name
                     AND  ao2.product_name = ao.product_name
                     AND  ao2.key_value    = ao.key_value)
UNION ALL
SELECT distinct ao.key_name
      ,ao.product_name
      ,ao.key_value
FROM   hr_s_application_ownerships ao
      ,pay_balance_types         pbt
WHERE  pbt.legislation_code     = 'ZZ'
  AND  ao.key_name             = 'BALANCE_TYPE_ID'
  AND  TO_NUMBER(ao.key_value) = pbt.balance_type_id
  AND  NOT EXISTS (SELECT null
                   FROM   hr_application_ownerships ao2
                   WHERE  ao2.key_name     = ao.key_name
                     AND  ao2.product_name = ao.product_name
                     AND  ao2.key_value    = ao.key_value)
UNION ALL
SELECT distinct ao.key_name
      ,ao.product_name
      ,ao.key_value
FROM   hr_s_application_ownerships ao
      ,pay_balance_dimensions pbd
WHERE  pbd.legislation_code ='ZZ'
  AND  ao.key_name          = 'BALANCE_DIMENSION_ID'
  AND  TO_NUMBER(ao.key_value) = pbd.balance_dimension_id
  AND  NOT EXISTS (SELECT null
                   FROM   hr_application_ownerships ao2
                   WHERE  ao2.key_name     = ao.key_name
                     AND  ao2.product_name = ao.product_name
                     AND  ao2.key_value    = ao.key_value)
UNION ALL
SELECT distinct ao.key_name
      ,ao.product_name
      ,ao.key_value
FROM   hr_s_application_ownerships ao
      ,pay_defined_balances pdb
WHERE  pdb.legislation_code ='ZZ'
  AND  ao.key_name          = 'DEFINED_BALANCE_ID'
  AND  TO_NUMBER(ao.key_value) = pdb.defined_balance_id
  AND  NOT EXISTS (SELECT null
                   FROM   hr_application_ownerships ao2
                   WHERE  ao2.key_name     = ao.key_name
                     AND  ao2.product_name = ao.product_name
                     AND  ao2.key_value    = ao.key_value)
UNION ALL
SELECT distinct ao.key_name
      ,ao.product_name
      ,ao.key_value
FROM   hr_s_application_ownerships ao
      ,ff_routes fr
      ,pay_balance_dimensions pbd
WHERE  pbd.legislation_code ='ZZ'
  AND  ao.key_name          = 'ROUTE_ID'
  AND  TO_NUMBER(ao.key_value) = fr.route_id
  AND  fr.route_id = pbd.route_id
  AND  NOT EXISTS (SELECT null
                   FROM   hr_application_ownerships ao2
                   WHERE  ao2.key_name     = ao.key_name
                     AND  ao2.product_name = ao.product_name
                     AND  ao2.key_value    = ao.key_value);
Line: 615

    l_inst_rowid	 rowid;		-- rowid of the installed row to update
Line: 616

    l_null_return varchar2(1);  	-- used for 'select null' statements
Line: 619

    CURSOR stu				-- Selects all rows from startup entity
    IS
	select user_status
	,      per_system_status
	,      pay_system_status
	,      default_flag
	,      rowid
	,      assignment_status_type_id c_surrogate_key
	,      last_update_date
	,      legislation_code c_leg_code
	,      null c_leg_sgrp
	from   hr_s_assignment_status_types;
Line: 632

    stu_rec stu%ROWTYPE;			-- Record for above SELECT
Line: 648

               insert_hr_stu_exceptions('per_assignment_status_types'
               ,      stu_rec.c_surrogate_key
               ,      exception_type
               ,      'User: ' || stu_rec.user_status ||
                      ' PER: ' || stu_rec.per_system_status ||
                      ' PAY: ' || stu_rec.pay_system_status);
Line: 669

	-- 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 count(*)
            into cnt
            from hr_s_assignment_status_types;
Line: 696

	    select distinct null
	    into   l_null_return
	    from   per_assignment_status_types a
	    where  exists
		(select null
		 from   hr_s_assignment_status_types b
		 where a.assignment_status_type_id=b.assignment_status_type_id
		);
Line: 706

	    --update all assignment_status_type_id's to remove conflict

	    update /*+NO_INDEX*/ hr_s_assignment_status_types
	    set assignment_status_type_id=assignment_status_type_id - 50000000;
Line: 711

            update /*+NO_INDEX*/ hr_s_status_processing_rules_f
            set assignment_status_type_id=assignment_status_type_id - 50000000;
Line: 714

	    update hr_s_application_ownerships
	    set    key_value = key_value - 50000000
	    where  key_name = 'ASSIGNMENT_STATUS_TYPE_ID';
Line: 722

	select min(assignment_status_type_id) - (count(*) *3)
	,      max(assignment_status_type_id) + (count(*) *3)
	into   v_min_delivered
	,      v_max_delivered
	from   hr_s_assignment_status_types;
Line: 728

        select max(assignment_status_type_id)
        into   v_max_live
        from   per_assignment_status_types;
Line: 732

	select per_assignment_status_types_s.nextval
	into   v_sequence_number
	from   dual;
Line: 768

    PROCEDURE update_uid
    --------------------
    IS

    BEGIN

	BEGIN
	    select distinct assignment_status_type_id
	    into   l_new_surrogate_key
	    from   per_assignment_status_types
	    where  user_status = stu_rec.user_status
	    and    per_system_status = stu_rec.per_system_status
	    and    business_group_id is null
	    and (  (pay_system_status is null and stu_rec.pay_system_status is null)
	        or (pay_system_status = stu_rec.pay_system_status) )
            and (  (legislation_code is null and  stu_rec.c_leg_code is null)
                or (legislation_code = stu_rec.c_leg_code) );
Line: 788

	    select per_assignment_status_types_s.nextval
	    into   l_new_surrogate_key
	    from   dual;
Line: 807

	update hr_s_assignment_status_types
	set    assignment_status_type_id = l_new_surrogate_key
	where  assignment_status_type_id = stu_rec.c_surrogate_key;
Line: 811

	update hr_s_status_processing_rules_f
	set    assignment_status_type_id = l_new_surrogate_key
	where  assignment_status_type_id = stu_rec.c_surrogate_key;
Line: 815

	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 = 'ASSIGNMENT_STATUS_TYPE_ID';
Line: 820

    END update_uid;
Line: 831

	    delete from hr_s_assignment_status_types
	    where  rowid = stu_rec.rowid;
Line: 835

	    delete from per_assignment_status_types
	    where  rowid = l_inst_rowid;
Line: 852

	-- 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.

	IF p_phase <> 1 THEN return TRUE; END IF;
Line: 874

	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 = 'ASSIGNMENT_STATUS_TYPE_ID'
	    and    a.key_value = l_new_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: 906

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

	l_inst_row number(1);
Line: 923

	    select distinct 1
	    into   l_inst_row
	    from   per_assignment_status_types
	    where  user_status = stu_rec.user_status
	    and    per_system_status = stu_Rec.per_system_status
	    and    business_group_id is null
	    and (  (pay_system_status is null and stu_rec.pay_system_status is null)
	        or (pay_system_status = stu_rec.pay_system_status) )
	    and (  (legislation_code is null and stu_rec.c_leg_code is null)
                or (legislation_code = stu_rec.c_leg_code) );
Line: 945

		    select null
		    into   l_null_return
		    from   dual
		    where  exists (

			select null
			from   per_assignment_status_types a
			,      per_business_groups b
			where  a.default_flag = 'Y'
			and    a.per_system_status = stu_rec.per_system_status
			and    ( (a.business_group_id is not null
		    	   and b.business_group_id = a.business_group_id
		       	   and b.legislation_code =
			       nvl(stu_rec.c_leg_code,b.legislation_code) )
			or     (a.business_group_id is null
		       	   and nvl(a.legislation_code,'X') =
		               nvl(stu_rec.c_leg_code,'X') ) ));
Line: 982

	-- 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.

	-- The local variable 'l_inst_rowid' is used to decide if there is
	-- a live row present or not. If this variable is not null it will
	-- contain the rowid of the installed row to  be updated.

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

	IF l_inst_row is null THEN

	    insert into per_assignment_status_types
		(ASSIGNMENT_STATUS_TYPE_ID
		,BUSINESS_GROUP_ID
		,LEGISLATION_CODE
		,ACTIVE_FLAG
		,DEFAULT_FLAG
		,PRIMARY_FLAG
		,USER_STATUS
		,PAY_SYSTEM_STATUS
		,PER_SYSTEM_STATUS
		,LAST_UPDATE_DATE
		,LAST_UPDATED_BY
		,LAST_UPDATE_LOGIN
		,CREATED_BY
		,CREATION_DATE)
		select ASSIGNMENT_STATUS_TYPE_ID
		    ,BUSINESS_GROUP_ID
		    ,LEGISLATION_CODE
		    ,ACTIVE_FLAG
		    ,DEFAULT_FLAG
		    ,PRIMARY_FLAG
		    ,USER_STATUS
		    ,PAY_SYSTEM_STATUS
		    ,PER_SYSTEM_STATUS
		    ,LAST_UPDATE_DATE
		    ,LAST_UPDATED_BY
		    ,LAST_UPDATE_LOGIN
		    ,CREATED_BY
		    ,CREATION_DATE
		from hr_s_assignment_status_types
		where rowid = stu_rec.rowid;
Line: 1035

	-- Delete delivered row now it has been installed

	remove('D');
Line: 1063

	IF p_phase = 1 THEN update_uid; END IF;
Line: 1090

        select max(effective_end_date) c_end
        ,      BALANCE_CATEGORY_ID c_surrogate_key
        ,      CATEGORY_NAME c_true_key
        ,      legislation_code
        from   hr_s_balance_categories_f
        group  by BALANCE_CATEGORY_ID
        ,         CATEGORY_NAME
        ,         legislation_code;
Line: 1105

        select *
        from   hr_s_balance_categories_f
        where  BALANCE_CATEGORY_ID = pc_bal_cat_id;
Line: 1126

            select count(*)
            into cnt
            from hr_s_balance_categories_f;
Line: 1132

            select distinct null
            into   l_null_return
            from   pay_balance_categories_f a
            where  exists
                (select null
                 from   hr_s_balance_categories_f b
                 where  a.BALANCE_CATEGORY_ID = b.BALANCE_CATEGORY_ID
                );
Line: 1144

            update /*+NO_INDEX*/ hr_s_balance_categories_f
            set    BALANCE_CATEGORY_ID = BALANCE_CATEGORY_ID - 50000000;
Line: 1147

            update /*+NO_INDEX*/ hr_s_balance_types
            set    BALANCE_CATEGORY_ID = BALANCE_CATEGORY_ID - 50000000;
Line: 1154

        select min(BALANCE_CATEGORY_ID) - (count(*) *3)
        ,      max(BALANCE_CATEGORY_ID) + (count(*) *3)
        into   v_min_delivered
        ,      v_max_delivered
        from   hr_s_balance_categories_f;
Line: 1160

        select max(BALANCE_CATEGORY_ID)
        into   v_max_live
        from   pay_balance_categories_f;
Line: 1164

        select pay_balance_categories_s.nextval
        into   v_sequence_number
        from   dual;
Line: 1199

        insert_hr_stu_exceptions('pay_balance_categories_f'
        ,      r_distinct.c_surrogate_key
        ,      exception_type
        ,      r_distinct.c_true_key);
Line: 1214

        delete from hr_s_balance_categories_f
        where  BALANCE_CATEGORY_ID = v_id;
Line: 1219

    PROCEDURE update_uid
    --------------------
    IS

    BEGIN

        BEGIN

            select distinct BALANCE_CATEGORY_ID
            into   l_new_balance_category_id
            from   pay_balance_categories_f
            where  category_name = r_distinct.c_true_key
            and    business_Group_id is null
            and    nvl(legislation_code, 'x') = nvl(r_distinct.legislation_code,'x');
Line: 1236

            select pay_balance_categories_s.nextval
            into   l_new_balance_category_id
            from   dual;
Line: 1247

        update hr_s_balance_categories_f
        set    balance_category_id = l_new_balance_category_id
        where  balance_category_id = r_distinct.c_surrogate_key;
Line: 1251

        update hr_s_balance_types
        set    balance_category_id = l_new_balance_category_id
        where  balance_category_id = r_distinct.c_surrogate_key;
Line: 1255

    END update_uid;
Line: 1275

            select distinct null
            into   l_null_return
            from   pay_balance_categories_f a
            where  a.category_name = r_distinct.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(r_distinct.legislation_code,b.legislation_code));
Line: 1301

            select distinct null
            into   l_null_return
            from   pay_balance_categories_f
            where  category_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);
Line: 1347

                    update_uid;
Line: 1350

                    delete from pay_balance_categories_f
                    where  balance_category_id = r_distinct.c_surrogate_key;
Line: 1359

                        insert into pay_balance_categories_f
                        ( BALANCE_CATEGORY_ID
                          ,CATEGORY_NAME
                          ,EFFECTIVE_START_DATE
                          ,EFFECTIVE_END_DATE
                          ,LEGISLATION_CODE
                          ,BUSINESS_GROUP_ID
                          ,SAVE_RUN_BALANCE_ENABLED
                          ,PBC_INFORMATION_CATEGORY
                          ,PBC_INFORMATION1
                          ,PBC_INFORMATION2
                          ,PBC_INFORMATION3
                          ,PBC_INFORMATION4
                          ,PBC_INFORMATION5
                          ,PBC_INFORMATION6
                          ,PBC_INFORMATION7
                          ,PBC_INFORMATION8
                          ,PBC_INFORMATION9
                          ,PBC_INFORMATION10
                          ,PBC_INFORMATION11
                          ,PBC_INFORMATION12
                          ,PBC_INFORMATION13
                          ,PBC_INFORMATION14
                          ,PBC_INFORMATION15
                          ,PBC_INFORMATION16
                          ,PBC_INFORMATION17
                          ,PBC_INFORMATION18
                          ,PBC_INFORMATION19
                          ,PBC_INFORMATION20
                          ,PBC_INFORMATION21
                          ,PBC_INFORMATION22
                          ,PBC_INFORMATION23
                          ,PBC_INFORMATION24
                          ,PBC_INFORMATION25
                          ,PBC_INFORMATION26
                          ,PBC_INFORMATION27
                          ,PBC_INFORMATION28
                          ,PBC_INFORMATION29
                          ,PBC_INFORMATION30
                          ,LAST_UPDATE_DATE
                          ,LAST_UPDATED_BY
                          ,LAST_UPDATE_LOGIN
                          ,CREATED_BY
                          ,CREATION_DATE
                          ,OBJECT_VERSION_NUMBER
                          ,USER_CATEGORY_NAME)
                        values
                        (each_row.BALANCE_CATEGORY_ID
                        ,each_row.CATEGORY_NAME
                        ,each_row.EFFECTIVE_START_DATE
                        ,each_row.EFFECTIVE_END_DATE
                        ,each_row.LEGISLATION_CODE
                        ,each_row.BUSINESS_GROUP_ID
                        ,each_row.SAVE_RUN_BALANCE_ENABLED
                        ,each_row.PBC_INFORMATION_CATEGORY
                        ,each_row.PBC_INFORMATION1
                        ,each_row.PBC_INFORMATION2
                        ,each_row.PBC_INFORMATION3
                        ,each_row.PBC_INFORMATION4
                        ,each_row.PBC_INFORMATION5
                        ,each_row.PBC_INFORMATION6
                        ,each_row.PBC_INFORMATION7
                        ,each_row.PBC_INFORMATION8
                        ,each_row.PBC_INFORMATION9
                        ,each_row.PBC_INFORMATION10
                        ,each_row.PBC_INFORMATION11
                        ,each_row.PBC_INFORMATION12
                        ,each_row.PBC_INFORMATION13
                        ,each_row.PBC_INFORMATION14
                        ,each_row.PBC_INFORMATION15
                        ,each_row.PBC_INFORMATION16
                        ,each_row.PBC_INFORMATION17
                        ,each_row.PBC_INFORMATION18
                        ,each_row.PBC_INFORMATION19
                        ,each_row.PBC_INFORMATION20
                        ,each_row.PBC_INFORMATION21
                        ,each_row.PBC_INFORMATION22
                        ,each_row.PBC_INFORMATION23
                        ,each_row.PBC_INFORMATION24
                        ,each_row.PBC_INFORMATION25
                        ,each_row.PBC_INFORMATION26
                        ,each_row.PBC_INFORMATION27
                        ,each_row.PBC_INFORMATION28
                        ,each_row.PBC_INFORMATION29
                        ,each_row.PBC_INFORMATION30
                        ,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.OBJECT_VERSION_NUMBER
                        ,nvl(each_row.USER_CATEGORY_NAME,
                             each_row.CATEGORY_NAME));
Line: 1506

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

    CURSOR stu				-- Selects all rows from startup entity
    IS

	select balance_name c_true_key
	,      balance_type_id c_surrogate_key
	,      legislation_code c_leg_code
	,      legislation_subgroup c_leg_sgrp
	,      assignment_remuneration_flag
	,      currency_code
	,      balance_uom
	,      reporting_name
	,      jurisdiction_level
        ,      tax_type
	,      last_update_date
	,      last_updated_by
	,      last_update_login
	,      created_by
	,      creation_date
        ,      input_value_id
        ,      base_balance_type_id
        ,      balance_category_id
	,      rowid
        ,      new_balance_type_flag
	from   hr_s_balance_types;
Line: 1540

	select distinct *
	from   hr_s_balance_classifications hsbc
	where  balance_type_id = bal_type_id
        and not exists
          ( select 1
            from  pay_balance_classifications pbc
            where nvl(hsbc.business_group_id, -1) = nvl(pbc.business_group_id, -1)
            and   hsbc.legislation_code     = pbc.legislation_code
            and   hsbc.balance_type_id      = pbc.balance_type_id
            and   hsbc.classification_id    = pbc.classification_id
            and   hsbc.scale                = pbc.scale
            and   nvl(hsbc.legislation_subgroup, 'X') = nvl(pbc.legislation_subgroup, 'X'));
Line: 1558

	select distinct *
	from   hr_s_defined_balances
	where  balance_type_id = bal_type_id;
Line: 1567

	select distinct *
   	from   hr_s_balance_feeds_f hrs
   	where  hrs.balance_type_id = bal_type_id
        and not exists (
                select null
                from pay_balance_feeds_f pbf
                where pbf.balance_type_id = hrs.balance_type_id
                and pbf.input_value_id = hrs.input_value_id
                and pbf.effective_start_date = hrs.effective_start_date
                and pbf.effective_end_date = hrs.effective_end_date);
Line: 1578

    stu_rec stu%ROWTYPE;			-- Cursor for earlier select
Line: 1592

	-- 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 count(*)
            into cnt
            from hr_s_balance_types;
Line: 1619

	    select distinct null
	    into   l_null_return
	    from   pay_balance_types a
	    where  exists
		(select null
		 from   hr_s_balance_types b
		 where  a.balance_type_id = b.balance_type_id
		);
Line: 1629

	    --update all balance_type_id's to remove conflict

	    update /*+NO_INDEX*/ hr_s_BALANCE_CLASSIFICATIONS
	    set    balance_type_id = balance_type_id - 50000000;
Line: 1634

            update /*+NO_INDEX*/ hr_s_BALANCE_FEEDS_F
            set    balance_type_id = balance_type_id - 50000000;
Line: 1637

            update /*+NO_INDEX*/ hr_s_BALANCE_TYPES
            set    balance_type_id = balance_type_id - 50000000;
Line: 1640

            update /*+NO_INDEX*/ hr_s_BALANCE_TYPES
            set    base_balance_type_id = base_balance_type_id - 50000000;
Line: 1643

            update /*+NO_INDEX*/ hr_s_DEFINED_BALANCES
            set    balance_type_id = balance_type_id - 50000000;
Line: 1646

	    update hr_s_application_ownerships
	    set    key_value = key_value - 50000000
	    where  key_name = 'BALANCE_TYPE_ID';
Line: 1658

            select count(*)
            into cnt
            from hr_s_defined_balances;
Line: 1665

	    select distinct null
	    into   l_null_return
	    from   pay_defined_balances a
	    where  exists
		(select null
		 from   hr_s_defined_balances b
		 where  a.defined_balance_id = b.defined_balance_id
		);
Line: 1675

	    --update all balance_type_id's to remove conflict

	    update /*+NO_INDEX*/ hr_s_DEFINED_BALANCES
	    set    defined_balance_id = defined_balance_id - 50000000;
Line: 1684

	select min(balance_type_id) - (count(*) *3)
	,      max(balance_type_id) + (count(*) *3)
	into   v_min_delivered
	,      v_max_delivered
	from   hr_s_balance_types;
Line: 1690

        select max(balance_type_id)
        into   v_max_live
        from   pay_balance_types;
Line: 1694

	select pay_balance_types_s.nextval
	into   v_sequence_number
	from   dual;
Line: 1715

        select min(defined_balance_id) - (count(*) *3)
        ,      max(defined_balance_id) +(count(*) *3)
        into   v_min_delivered
        ,      v_max_delivered
        from   hr_s_defined_balances;
Line: 1721

        select pay_defined_balances_s.nextval
        into   v_sequence_number
        from   dual;
Line: 1746

        insert_hr_stu_exceptions('pay_balance_types'
            ,      stu_rec.c_surrogate_key
            ,      exception_type
            ,      stu_rec.c_true_key);
Line: 1753

    PROCEDURE update_uid
    --------------------
    IS
	v_new_def_bal_id number(15);
Line: 1763

	    select distinct balance_type_id
	    into   l_new_surrogate_key
	    from   pay_balance_types
            where  replace(ltrim(rtrim(upper(balance_name))), ' ', '_') =
                   replace(ltrim(rtrim(upper(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: 1777

	    select pay_balance_types_s.nextval
	    into   l_new_surrogate_key
	    from   dual;
Line: 1794

	-- Update all child entities

	update hr_s_balance_types
	set    balance_type_id = l_new_surrogate_key
	where  balance_type_id = stu_rec.c_surrogate_key;
Line: 1800

        update hr_s_balance_types
        set    base_balance_type_id = l_new_surrogate_key,
               new_balance_type_flag = v_new_balance_type_flag
        where  base_balance_type_id = stu_rec.c_surrogate_key;
Line: 1805

	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 = 'BALANCE_TYPE_ID';
Line: 1810

	update hr_s_balance_classifications
	set    balance_type_id = l_new_surrogate_key
	where  balance_type_id = stu_rec.c_surrogate_key;
Line: 1814

	update hr_s_balance_feeds_f
	set    balance_type_id = l_new_surrogate_key,
               new_balance_type_flag = v_new_balance_type_flag
	where  balance_type_id = stu_rec.c_surrogate_key;
Line: 1819

	-- Select the currently installed defined balance id, using
	-- the by now updated balance_dimension_id and the new balance_type_id.
	-- The balance_type_id will find its way onto the defined_balance row
	-- when the row is updated with a new surrogate key.

	FOR def_bals IN defined(stu_rec.c_surrogate_key) LOOP

	    BEGIN

		select defined_balance_id
		into   v_new_def_bal_id
		from   pay_defined_balances
		where  balance_type_id = l_new_surrogate_key
		and    balance_dimension_id = def_bals.balance_dimension_id
                and    business_group_id is null
                and (  (legislation_code is null and def_bals.legislation_code is null)
                    or (legislation_code = def_bals.legislation_code) );
Line: 1839

		select pay_defined_balances_s.nextval
		into   v_new_def_bal_id
		from   dual;
Line: 1858

	    update hr_s_defined_balances
	    set    defined_balance_id = v_new_def_bal_id
            ,      balance_type_id = l_new_surrogate_key
            where  defined_balance_id = def_bals.defined_balance_id
	    and    balance_type_id    = def_bals.balance_type_id;
Line: 1866

    END update_uid;
Line: 1876

	delete from hr_s_balance_classifications
	where  balance_type_id = stu_Rec.c_surrogate_key;
Line: 1880

	delete from hr_s_defined_balances
	where  balance_type_id = stu_Rec.c_surrogate_key;
Line: 1884

	delete from hr_s_balance_feeds_f
	where  balance_type_id = stu_Rec.c_surrogate_key;
Line: 1887

	delete from hr_s_balance_types
	where  rowid = stu_rec.rowid;
Line: 1907

        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 = 'BALANCE_TYPE_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: 1923

	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 = 'BALANCE_TYPE_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: 1970

        select /*+ INDEX_FFS(pb) */ business_group_id
        from   pay_balance_types pb
        where  business_group_id is not null
        and    replace(ltrim(rtrim(upper(balance_name))), ' ', '_') =
               replace(ltrim(rtrim(upper(stu_rec.c_true_key))), ' ', '_');
Line: 1986

	select status
	into   v_payroll_install_status
	from   fnd_product_installations
	where  application_id = 801;
Line: 2003

	       select distinct null
	       into   l_null_return
	       from   pay_balance_types a
	       where  a.business_group_id is not null
               and    replace(ltrim(rtrim(upper(a.balance_name))), ' ', '_') =
                      replace(ltrim(rtrim(upper(stu_rec.c_true_key))), ' ', '_');
Line: 2026

                   select distinct null
                   into   l_null_return
                   from   per_business_groups pbg
                   where  pbg.business_group_id = bals.business_group_id
                   and    pbg.legislation_code = stu_rec.c_leg_code;
Line: 2053

	       select distinct null
	       into   l_null_return
	       from   pay_balance_types
	       where  balance_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: 2074

	-- identical the delivered row will be deleted.

	-- The child rows will be deleted in the 'remove' function.

	-- If the balance type is to be installed, check the child
	-- defined balances. These children should be removed from the delivery
	-- tables if they match the installed rows. This check is performed in
	-- the exception handler, since this is where the installation of the
	-- balance type is first identified.
	--
	-- #331831. Add NVLs wherever values may be null, to prevent flagging
	-- rows which are identical but have some null values as different.
	--
	-- See comments in transfer_row procedure within install_past
	-- procedure.


	IF p_phase = 1 THEN return; END IF;
Line: 2095

          select distinct null
          into   l_null_return
          from   pay_balance_categories_f
          where  balance_category_id = stu_rec.balance_category_id;
Line: 2106

	update pay_balance_types
	set    business_group_id = null
	,      legislation_code = stu_rec.c_leg_code
	,      legislation_subgroup = stu_rec.c_leg_sgrp
	,      assignment_remuneration_flag=stu_rec.assignment_remuneration_flag
	,      currency_code = stu_rec.currency_code
	,      balance_uom = stu_rec.balance_uom
	,      reporting_name = stu_rec.reporting_name
	,      jurisdiction_level = stu_rec.jurisdiction_level
        ,      tax_type = stu_rec.tax_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
        ,      input_value_id = stu_rec.input_value_id
        ,      base_balance_type_id = stu_rec.base_balance_type_id
        ,      balance_category_id = stu_rec.balance_category_id
	where  balance_type_id = stu_rec.c_surrogate_key;
Line: 2130

	    -- No row there to update, must insert

           BEGIN
	    insert into pay_balance_types
	    (balance_name
	    ,balance_type_id
	    ,legislation_code
	    ,legislation_subgroup
	    ,assignment_remuneration_flag
	    ,currency_code
	    ,balance_uom
	    ,reporting_name
	    ,jurisdiction_level
            ,tax_type
	    ,last_update_date
	    ,last_updated_by
	    ,last_update_login
	    ,created_by
	    ,creation_date
            ,input_value_id
            ,base_balance_type_id
            ,balance_category_id )
	    values
	    (stu_rec.c_true_key
	    ,stu_rec.c_surrogate_key
	    ,stu_rec.c_leg_code
	    ,stu_rec.c_leg_sgrp
	    ,stu_rec.assignment_remuneration_flag
	    ,stu_rec.currency_code
	    ,stu_rec.balance_uom
	    ,stu_rec.reporting_name
	    ,stu_rec.jurisdiction_level
            ,stu_rec.tax_type
	    ,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.input_value_id
            ,stu_rec.base_balance_type_id
            ,stu_rec.balance_category_id);
Line: 2188

	-- At this stage the balance type is either installed new or updated.
	-- Therefore all balance classifications will be refreshed. The first
	-- stage is to delete those already there, then insert all
	-- classification rows in the delivery tables.
	--

    -- store balance feed currval for latest use - so don't delete any of the
    -- classification feeds created (if don't exist in hr_s)
    select pay_balance_feeds_s.nextval
    into   l_initbfid
    from   dual;
Line: 2205

	delete from pay_balance_classifications pbc
	where  balance_type_id = stu_rec.c_surrogate_key
        and not exists
          ( select 1
            from hr_s_balance_classifications hsbc
            where nvl(hsbc.business_group_id, -1) = nvl(pbc.business_group_id, -1)
            and   hsbc.legislation_code     = pbc.legislation_code
            and   hsbc.balance_type_id      = pbc.balance_type_id
            and   hsbc.classification_id    = pbc.classification_id
            and   hsbc.scale                = pbc.scale
            and   nvl(hsbc.legislation_subgroup, 'X') = nvl(pbc.legislation_subgroup, 'X'));
Line: 2220

	-- If the select raises an exception then the classification does not
	-- exist. Otherwise the row will be inserted.

	FOR bal_classes IN class(stu_rec.c_surrogate_key) LOOP


	    BEGIN
	        select distinct null
	        into   l_null_return
	        from   pay_element_classifications
	        where  classification_id = bal_classes.classification_id;
Line: 2239

	    insert into pay_balance_classifications
	    (BALANCE_CLASSIFICATION_ID
	    ,BUSINESS_GROUP_ID
	    ,LEGISLATION_CODE
	    ,BALANCE_TYPE_ID
	    ,CLASSIFICATION_ID
	    ,SCALE
	    ,LEGISLATION_SUBGROUP
	    ,LAST_UPDATE_DATE
	    ,LAST_UPDATED_BY
	    ,LAST_UPDATE_LOGIN
	    ,CREATED_BY
	    ,CREATION_DATE)
	    select pay_balance_classifications_s.nextval
	    ,      bal_classes.business_group_id
	    ,      bal_classes.legislation_code
	    ,      bal_classes.balance_type_id
	    ,      bal_classes.classification_id
	    ,      bal_classes.scale
	    ,      bal_classes.legislation_subgroup
	    ,      bal_classes.last_update_date
	    ,      bal_classes.last_updated_by
	    ,      bal_classes.last_update_login
	    ,      bal_classes.created_by
	    ,      bal_classes.creation_date
	    from dual;
Line: 2286

           select pay_balance_classifications_s.currval
           into   l_bal_class_id
           from   dual;
Line: 2305

	-- the select raises an exception then the dimension does not exist.
	-- Otherwise the row will be inserted. At this stage the
	-- defined_balance_id will not exist in the live tables. Consequently
	-- only new defined_balances will remain in the delivery tables.

	FOR def_bals IN defined(stu_rec.c_surrogate_key) LOOP


	    BEGIN
		select distinct null
		into   l_null_return
		from   pay_balance_dimensions
		where  balance_dimension_id = def_bals.balance_dimension_id;
Line: 2325

            update pay_defined_balances
            set BUSINESS_GROUP_ID = null,
                LEGISLATION_CODE = def_bals.LEGISLATION_CODE,
                BALANCE_TYPE_ID = def_bals.BALANCE_TYPE_ID,
                BALANCE_DIMENSION_ID = def_bals.BALANCE_DIMENSION_ID,
                FORCE_LATEST_BALANCE_FLAG = def_bals.FORCE_LATEST_BALANCE_FLAG,
                LEGISLATION_SUBGROUP = def_bals.LEGISLATION_SUBGROUP,
                LAST_UPDATE_DATE = def_bals.LAST_UPDATE_DATE,
                LAST_UPDATED_BY = def_bals.LAST_UPDATED_BY,
                LAST_UPDATE_LOGIN = def_bals.LAST_UPDATE_LOGIN,
                CREATED_BY = def_bals.CREATED_BY,
                CREATION_DATE = def_bals.CREATION_DATE,
                GROSSUP_ALLOWED_FLAG = def_bals.GROSSUP_ALLOWED_FLAG,
                SAVE_RUN_BALANCE = def_bals.SAVE_RUN_BALANCE
            --    RUN_BALANCE_STATUS = def_bals.RUN_BALANCE_STATUS
            where DEFINED_BALANCE_ID = def_bals.defined_balance_id;
Line: 2345

	      insert into pay_defined_balances
	      (DEFINED_BALANCE_ID
	      ,BUSINESS_GROUP_ID
	      ,LEGISLATION_CODE
	      ,BALANCE_TYPE_ID
	      ,BALANCE_DIMENSION_ID
	      ,FORCE_LATEST_BALANCE_FLAG
	      ,LEGISLATION_SUBGROUP
	      ,LAST_UPDATE_DATE
	      ,LAST_UPDATED_BY
	      ,LAST_UPDATE_LOGIN
	      ,CREATED_BY
	      ,CREATION_DATE
	      ,GROSSUP_ALLOWED_FLAG
              ,SAVE_RUN_BALANCE
              ,RUN_BALANCE_STATUS)
	      values
	      (def_bals.defined_balance_id
	      ,null
	      ,def_bals.legislation_code
	      ,def_bals.balance_type_id
	      ,def_bals.balance_dimension_id
	      ,def_bals.force_latest_balance_flag
	      ,def_bals.legislation_subgroup
	      ,def_bals.last_update_date
	      ,def_bals.last_updated_by
	      ,def_bals.last_update_login
	      ,def_bals.created_by
	      ,def_bals.creation_date
	      ,def_bals.grossup_allowed_flag
              ,def_bals.save_run_balance
              ,def_bals.run_balance_status);
Line: 2416

        delete from pay_balance_feeds_f pbf
        where pbf.balance_type_id = stu_rec.c_surrogate_key
        and   pbf.business_group_id is null
        and   pbf.legislation_code is not null
        and   pbf.balance_feed_id <= l_initbfid
             and not exists (
                select null
                from hr_s_balance_feeds_f hrs
                where pbf.balance_type_id = hrs.balance_type_id
                and pbf.input_value_id = hrs.input_value_id
                and pbf.effective_start_date = hrs.effective_start_date
                and pbf.effective_end_date = hrs.effective_end_date);
Line: 2432

	-- the select raises an exception then the input value does not exist.
	-- Otherwise the row will be inserted.

	FOR bal_feeds IN feed(stu_rec.c_surrogate_key) LOOP


	    BEGIN
	        select distinct null
	        into   l_null_return
	        from   pay_input_values_f
	        where  input_value_id = bal_feeds.input_value_id;
Line: 2458

	    insert into pay_balance_feeds_f
	    (balance_feed_id
	    ,effective_start_date
	    ,effective_end_date
	    ,business_group_id
	    ,legislation_code
	    ,balance_type_id
	    ,input_value_id
	    ,scale
	    ,legislation_subgroup
	    ,last_update_date
	    ,last_updated_by
	    ,last_update_login
	    ,created_by
	    ,creation_date)
	    select pay_balance_feeds_s.nextval
	    ,bal_feeds.effective_start_date
	    ,bal_feeds.effective_end_date
	    ,bal_feeds.business_group_id
	    ,bal_feeds.legislation_code
	    ,bal_feeds.balance_type_id
	    ,bal_feeds.input_value_id
	    ,bal_feeds.scale
	    ,bal_feeds.legislation_subgroup
	    ,bal_feeds.last_update_date
	    ,bal_feeds.last_updated_by
	    ,bal_feeds.last_update_login
	    ,bal_feeds.created_by
	    ,bal_feeds.creation_date
	    from dual;
Line: 2538

	    IF p_phase = 1 THEN update_uid; END IF;
Line: 2554

    l_null_return varchar2(1);		-- used for 'select null' statements
Line: 2558

    CURSOR stu				-- selects all rows from startup entity
    IS
	select dimension_name c_true_key
	,      balance_dimension_id c_surrogate_key
	,      route_id
	,      legislation_code c_leg_code
	,      legislation_subgroup c_leg_sgrp
	,      database_item_suffix
	,      dimension_type
	,      description
	,      feed_checking_code
	,      feed_checking_type
	,      payments_flag
	,      expiry_checking_code
	,      expiry_checking_level
        ,      dimension_level
        ,      period_type
        ,      asg_action_balance_dim_id
        ,      database_item_function
        ,      save_run_balance_enabled
        ,      start_date_code
	,      rowid
	from   hr_s_balance_dimensions;
Line: 2582

    stu_rec stu%ROWTYPE;			-- Record for the above select
Line: 2596

	-- 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 count(*)
            into cnt
            from hr_s_balance_dimensions;
Line: 2625

	    select distinct null
	    into   l_null_return
	    from   pay_balance_dimensions a
	    where  exists
		(select null
		 from   hr_s_balance_dimensions b
		 where  a.balance_dimension_id = b.balance_dimension_id
		);
Line: 2635

	    --update all balance_dimension_id's to remove conflict

	    update /*+NO_INDEX*/ hr_s_balance_dimensions
	    set    balance_dimension_id = balance_dimension_id - 50000000;
Line: 2640

	    update /*+NO_INDEX*/  hr_s_defined_balances
            set    balance_dimension_id = balance_dimension_id - 50000000;
Line: 2643

            update /*+NO_INDEX*/ hr_s_balance_dimensions
            set    asg_action_balance_dim_id = asg_action_balance_dim_id
                                                   - 50000000;
Line: 2647

            update /*+NO_INDEX*/ hr_s_dimension_routes
            set    balance_dimension_id = balance_dimension_id - 50000000;
Line: 2650

            update /*+NO_INDEX*/ hr_s_dimension_routes
            set    run_dimension_id = run_dimension_id - 50000000;
Line: 2653

	    update hr_s_application_ownerships
	    set    key_value = key_value - 50000000
	    where  key_name = 'BALANCE_DIMENSION_ID';
Line: 2663

	select min(balance_dimension_id) - (count(*) *3)
	,      max(balance_dimension_id) + (count(*) *3)
	into   v_min_delivered
	,      v_max_delivered
	from   hr_s_balance_dimensions;
Line: 2669

        select max(balance_dimension_id)
        into   v_max_live
        from   pay_balance_dimensions;
Line: 2673

	select pay_balance_dimensions_s.nextval
	into   v_sequence_number
	from   dual;
Line: 2706

        insert_hr_stu_exceptions('pay_balance_dimensions'
        ,      stu_rec.c_surrogate_key
        ,      exception_type
        ,      stu_rec.c_true_key);
Line: 2714

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

    BEGIN

	BEGIN
	    select distinct balance_dimension_id
	    into   l_new_surrogate_key
	    from   pay_balance_dimensions
	    where  dimension_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: 2732

	    select pay_balance_dimensions_s.nextval
	    into   l_new_surrogate_key
	    from   dual;
Line: 2747

	-- Update all child entities


	update hr_s_balance_dimensions
	set    balance_dimension_id = l_new_surrogate_key
	where  balance_dimension_id = stu_rec.c_surrogate_key;
Line: 2754

	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 = 'BALANCE_DIMENSION_ID';
Line: 2759

	update hr_s_defined_balances
	set    balance_dimension_id = l_new_surrogate_key
	where  balance_dimension_id = stu_rec.c_surrogate_key;
Line: 2763

        update hr_s_dimension_routes
        set    balance_dimension_id = l_new_surrogate_key
        where  balance_dimension_id = stu_rec.c_surrogate_key;
Line: 2767

        update hr_s_dimension_routes
        set    run_dimension_id = l_new_surrogate_key
        where  run_dimension_id = stu_rec.c_surrogate_key;
Line: 2771

        update hr_s_balance_dimensions
        set    asg_action_balance_dim_id = l_new_surrogate_key
        where  asg_action_balance_dim_id = stu_rec.c_surrogate_key;
Line: 2776

    END update_uid;
Line: 2785

	delete from hr_s_balance_dimensions
	where  rowid = stu_rec.rowid;
Line: 2795

    l_null_return varchar2(1);          -- used for 'select null' statements
Line: 2807

        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 = 'BALANCE_DIMENSION_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: 2823

        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 = 'BALANCE_DIMENSION_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: 2867

	-- 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.


   	BEGIN

	    -- Start the checking against the first parent table

	    select distinct null
	    into   l_null_return
	    from   hr_s_routes
	    where  route_id = stu_rec.route_id;
Line: 2904

	    select null
	    into   l_null_return
	    from   ff_routes
	    where  route_id = stu_rec.route_id;
Line: 2928

	v_inst_update date;  		-- Hold update details of installed row
Line: 2932

            select distinct null
            from pay_balance_dimensions a
            where a.dimension_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: 2941

            select distinct null
            from   pay_balance_dimensions
            where  dimension_name = stu_rec.c_true_key
            and    legislation_code <> stu_rec.c_leg_code
            and    (legislation_code is null or stu_rec.c_leg_code is null);
Line: 2993

	-- identical the delivered row will be deleted.

	delete from hr_s_balance_dimensions a
	where  a.balance_dimension_id = stu_rec.c_surrogate_key
	and    exists (
         select 1 from pay_balance_dimensions b
         where  a.ROUTE_ID = b.route_id
         and    a.DATABASE_ITEM_SUFFIX = b.DATABASE_ITEM_SUFFIX
         and    a.DIMENSION_TYPE = b.DIMENSION_TYPE
         and    length(a.FEED_CHECKING_CODE) = length(b.FEED_CHECKING_CODE)
         and    a.FEED_CHECKING_TYPE = b.FEED_CHECKING_TYPE
         and    a.PAYMENTS_FLAG = b.PAYMENTS_FLAG
         and    length(a.EXPIRY_CHECKING_CODE) = length(b.EXPIRY_CHECKING_CODE)
         and    a.EXPIRY_CHECKING_LEVEL = b.EXPIRY_CHECKING_LEVEL
         and    a.DIMENSION_LEVEL = b.DIMENSION_LEVEL
         and    a.PERIOD_TYPE = b.PERIOD_TYPE);
Line: 3017

	-- 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.

	IF NOT check_parents THEN return; END IF;
Line: 3031

	-- 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
	-- transferred row from the delivery tables.

        -- Delete the user entity for a dimension if its
        -- about to have its route_id changed.  Bug 4328538.

        BEGIN

        select route_id
        into l_route_id
        from pay_balance_dimensions
        where balance_dimension_id = stu_rec.c_surrogate_key;
Line: 3054

          delete ff_compiled_info_f
          where formula_id in (
           select fdi.formula_id
           from   ff_fdi_usages_f fdi,
                  ff_user_entities ue,
                  pay_defined_balances db,
                  pay_balance_dimensions bd,
                  ff_database_items di
           where fdi.item_name = di.user_name
           and   ue.creator_type = 'B'
           and   ue.creator_id = db.defined_balance_id
           and   bd.balance_dimension_id = db.balance_dimension_id
           and   bd.balance_dimension_id = stu_rec.c_surrogate_key
           and   di.user_entity_id = ue.user_entity_id);
Line: 3069

          delete from ff_fdi_usages_f fdi2
          where fdi2.formula_id in
          (select fdi.formula_id
           from   ff_fdi_usages_f fdi,
                  ff_user_entities ue,
                  pay_defined_balances db,
                  pay_balance_dimensions bd,
                  ff_database_items di
           where fdi.item_name = di.user_name
           and   ue.creator_type = 'B'
           and   ue.creator_id = db.defined_balance_id
           and   bd.balance_dimension_id = db.balance_dimension_id
           and   bd.balance_dimension_id = stu_rec.c_surrogate_key
           and   di.user_entity_id = ue.user_entity_id);
Line: 3084

          delete from ff_user_entities
          where creator_type = 'B'
          and creator_id in
              (select defined_balance_id
               from pay_defined_balances pdb
               where pdb.balance_dimension_id = stu_rec.c_surrogate_key);
Line: 3093

	update pay_balance_dimensions
	set route_id = stu_rec.route_id
	,   database_item_suffix = stu_rec.database_item_suffix
	,   dimension_type = stu_rec.dimension_type
	,   description = stu_rec.description
	,   feed_checking_code = stu_rec.feed_checking_code
	,   feed_checking_type = stu_rec.feed_checking_type
	,   payments_flag = stu_rec.payments_flag
	,   expiry_checking_code = stu_rec.expiry_checking_code
	,   expiry_checking_level = stu_rec.expiry_checking_level
        ,   dimension_level = stu_rec.dimension_level
        ,   period_type = stu_rec.period_type
        ,   asg_action_balance_dim_id = stu_rec.asg_action_balance_dim_id
        ,   database_item_function = stu_rec.database_item_function
        ,   save_run_balance_enabled = stu_rec.save_run_balance_enabled
        ,   start_date_code = stu_rec.start_date_code
	where  balance_dimension_id = stu_rec.c_surrogate_key;
Line: 3113

	    insert into pay_balance_dimensions
	    (dimension_name
	    ,balance_dimension_id
	    ,route_id
	    ,legislation_code
	    ,legislation_subgroup
	    ,database_item_suffix
	    ,dimension_type
	    ,description
	    ,feed_checking_code
	    ,feed_checking_type
	    ,payments_flag
	    ,expiry_checking_code
	    ,expiry_checking_level
            ,dimension_level
            ,period_type
            ,asg_action_balance_dim_id
            ,database_item_function
            ,save_run_balance_enabled
            ,start_date_code
	    )
	    values
	    (stu_rec.c_true_key
	    ,stu_rec.c_surrogate_key
	    ,stu_rec.route_id
	    ,stu_rec.c_leg_code
	    ,stu_rec.c_leg_sgrp
	    ,stu_rec.database_item_suffix
	    ,stu_rec.dimension_type
	    ,stu_rec.description
	    ,stu_rec.feed_checking_code
	    ,stu_rec.feed_checking_type
	    ,stu_rec.payments_flag
	    ,stu_rec.expiry_checking_code
	    ,stu_rec.expiry_checking_level
            ,stu_rec.dimension_level
            ,stu_rec.period_type
            ,stu_rec.asg_action_balance_dim_id
            ,stu_rec.database_item_function
            ,stu_rec.save_run_balance_enabled
            ,stu_rec.start_date_code);
Line: 3202

	    IF p_phase = 1 THEN update_uid; END IF;
Line: 3215

    l_null_return varchar2(1);       -- used for select null stmts
Line: 3219

    CURSOR stu                       -- selects all rows from startup entity
    IS
        select BALANCE_DIMENSION_ID
        ,      ROUTE_ID
        ,      ROUTE_TYPE
        ,      PRIORITY
        ,      RUN_DIMENSION_ID
        ,      BALANCE_TYPE_COLUMN
        ,      DECODE_REQUIRED
        ,      rowid
        from   hr_s_dimension_routes;
Line: 3231

    stu_rec stu%ROWTYPE;                        -- Record for the above select
Line: 3239

        delete from hr_s_dimension_routes
        where  rowid = stu_rec.rowid;
Line: 3254

        insert_hr_stu_exceptions('pay_dimension_routes'
        ,      stu_rec.BALANCE_DIMENSION_ID
        ,      exception_type
        ,      to_char(stu_rec.ROUTE_ID));
Line: 3270

            select distinct null
            into   l_null_return
            from   hr_s_balance_dimensions
            where  balance_dimension_id = stu_rec.balance_dimension_id;
Line: 3286

            select distinct null
            into   l_null_return
            from   pay_balance_dimensions
            where  balance_dimension_id = stu_rec.balance_dimension_id;
Line: 3300

            select distinct null
            into   l_null_return
            from   hr_s_routes
            where  route_id = stu_rec.route_id;
Line: 3316

            select distinct null
            into   l_null_return
            from   ff_routes
            where  route_id = stu_rec.route_id;
Line: 3344

            select route_id, run_dimension_id
            into l_route_id, l_run_dimension_id
            from pay_dimension_routes
            where BALANCE_DIMENSION_ID=stu_rec.BALANCE_DIMENSION_ID
            and   PRIORITY = stu_rec.PRIORITY;
Line: 3353

              delete ff_compiled_info_f fci
              where  fci.formula_id in (
                select fdi.formula_id
                from ff_fdi_usages_f fdi
                where  FDI.usage = 'D'
                and exists (select null from
                  ff_database_items dbi
                  where fdi.item_name  = dbi.user_name
                  and exists (select null from
                    ff_user_entities ent
                    where   ent.user_entity_id = dbi.user_entity_id
                    and     ent.creator_type in ('B', 'RB')
                    and     ent.route_id = stu_rec.route_id)));
Line: 3367

               delete ff_fdi_usages_f fdi
               where  FDI.usage = 'D'
               and exists (select null from
                ff_database_items dbi
                where fdi.item_name  = dbi.user_name
                and exists (select null from
                  ff_user_entities ent
                  where   ent.user_entity_id = dbi.user_entity_id
                  and     ent.creator_type in ('B', 'RB')
                  and     ent.route_id = stu_rec.route_id));
Line: 3378

               delete from ff_user_entities ue
               where creator_type in ('B', 'RB')
               and route_id = stu_rec.ROUTE_ID;
Line: 3388

        delete pay_dimension_routes
        where  BALANCE_DIMENSION_ID=stu_rec.BALANCE_DIMENSION_ID
        and    PRIORITY = stu_rec.PRIORITY;
Line: 3393

        insert into pay_dimension_routes
        (BALANCE_DIMENSION_ID
        ,ROUTE_ID
        ,ROUTE_TYPE
        ,PRIORITY
        ,RUN_DIMENSION_ID
        ,BALANCE_TYPE_COLUMN
        ,DECODE_REQUIRED)
        values
        (stu_rec.BALANCE_DIMENSION_ID
        ,stu_rec.ROUTE_ID
        ,stu_rec.ROUTE_TYPE
        ,stu_rec.PRIORITY
        ,stu_rec.RUN_DIMENSION_ID
        ,stu_rec.BALANCE_TYPE_COLUMN
        ,stu_rec.DECODE_REQUIRED);
Line: 3447

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

    CURSOR stu                          -- Selects all rows from startup entity
    IS
        select org_information_type
        ,      description
        ,      destination
        ,      displayed_org_information_type doit
        ,      legislation_code
        ,      navigation_method
        ,      fnd_application_id
        ,      rowid
        from   hr_s_org_information_types;
Line: 3461

    stu_rec stu%ROWTYPE;                        -- Record for above SELECT
Line: 3470

        delete from hr_s_org_information_types
        where  rowid = stu_rec.rowid;
Line: 3473

        delete from hr_s_org_info_types_by_class
        where  org_information_type = stu_rec.org_information_type;
Line: 3489

        select null
        into   l_null_return
        from   hr_org_information_types
        where  org_information_type = stu_rec.org_information_type
        and    nvl(destination,'X') = nvl(stu_rec.destination,'X')
        and    nvl(displayed_org_information_type,'X') = nvl(stu_rec.doit,'X')
        and    nvl(legislation_code,'X') = nvl(stu_rec.legislation_code,'X')
        and    nvl(navigation_method,'X') = nvl(stu_rec.navigation_method,'X');
Line: 3504

        select null
        into   l_null_return
        from   dual
        where  not exists
               ((select ORG_CLASSIFICATION,
                        ORG_INFORMATION_TYPE,
                        MANDATORY_FLAG,
                        ENABLED_FLAG
                 from   hr_s_org_info_types_by_class
                 where  org_information_type = stu_rec.org_information_type
                 MINUS
                 select ORG_CLASSIFICATION,
                        ORG_INFORMATION_TYPE,
                        MANDATORY_FLAG,
                        ENABLED_FLAG
                 from   hr_org_info_types_by_class
                 where  org_information_type = stu_rec.org_information_type
                )
                 UNION
                (select ORG_CLASSIFICATION,
                        ORG_INFORMATION_TYPE,
                        MANDATORY_FLAG,
                        ENABLED_FLAG
                 from   hr_org_info_types_by_class
                 where  org_information_type = stu_rec.org_information_type
                 MINUS
                 select ORG_CLASSIFICATION,
                        ORG_INFORMATION_TYPE,
                        MANDATORY_FLAG,
                        ENABLED_FLAG
                 from   hr_s_org_info_types_by_class
                 where  org_information_type = stu_rec.org_information_type
               ));
Line: 3555

        update hr_org_information_types
        set    destination = stu_rec.destination
        ,      displayed_org_information_type = stu_rec.doit
        ,      legislation_code = stu_rec.legislation_code
        ,      navigation_method = stu_rec.navigation_method
        where  org_information_type = stu_rec.org_information_type;
Line: 3565

            insert into hr_org_information_types
            (org_information_type
            ,description
            ,destination
            ,displayed_org_information_type
            ,fnd_application_id
            ,legislation_code
            ,navigation_method
             )
             values
             (stu_rec.org_information_type
             ,stu_rec.description
             ,stu_rec.destination
             ,stu_rec.doit
             ,stu_rec.fnd_application_id
             ,stu_rec.legislation_code
             ,stu_rec.navigation_method
             );
Line: 3587

        delete from hr_org_info_types_by_class
        where  org_information_type = stu_rec.org_information_type;
Line: 3591

        insert into hr_org_info_types_by_class
        (ORG_CLASSIFICATION
        ,ORG_INFORMATION_TYPE
        ,MANDATORY_FLAG
        ,ENABLED_FLAG
        )
        select org_classification
        ,      org_information_type
        ,      mandatory_flag
        ,      'Y' -- default to Y at least for now
        from   hr_s_org_info_types_by_class
        where  org_information_type = stu_rec.org_information_type;
Line: 3642

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

    CURSOR stu				-- Selects all rows from startup entity
    IS
	select information_type c_true_key
	,      active_inactive_flag
	,      description
	,      legislation_code c_leg_code
	,      request_id
	,      program_application_id
	,      program_id
	,      program_update_date
	,      last_update_date
	,      last_updated_by
	,      last_update_login
	,      created_by
	,      creation_date
	,      rowid
	,      multiple_occurences_flag
	from   hr_s_assignment_info_types;
Line: 3664

    stu_rec stu%ROWTYPE;			-- Cursor for earlier select
Line: 3682

        insert_hr_stu_exceptions('per_assignment_info_types'
        ,      0
        ,      exception_type
        ,      stu_rec.c_true_key);
Line: 3697

	delete from hr_s_assignment_info_types
	where  rowid = stu_rec.rowid;
Line: 3705

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

    BEGIN

	-- Perform a check to see if this primary key has been installed
	-- with a legislation code that would make it visible at the same time
	-- as this row. Ie: if any legislation code is null within the set of
	-- returned rows, then the transfer may not go ahead. If no rows are
	-- returned then the delivered row is fine.

	BEGIN
	    select distinct null
	    into   l_null_return
	    from   per_assignment_info_types
	    where  information_type = 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);
Line: 3734

	-- delivery tables, otherwise insert into the live table.


	BEGIN
	    select distinct null
	    into   l_null_return
	    from   per_assignment_info_types
	    where  legislation_code = stu_rec.c_leg_code
	    and    information_type = stu_rec.c_true_key;
Line: 3755

	    insert into per_assignment_info_types
	    (information_type
	    ,active_inactive_flag
	    ,description
	    ,legislation_code
	    ,request_id
	    ,program_application_id
	    ,program_id
	    ,program_update_date
	    ,last_update_date
	    ,last_updated_by
	    ,last_update_login
	    ,created_by
	    ,creation_date
	    ,multiple_occurences_flag
	    )
	    values
	    (stu_rec.c_true_key
	    ,stu_rec.active_inactive_flag
	    ,stu_rec.description
	    ,stu_rec.c_leg_code
	    ,stu_rec.request_id
	    ,stu_rec.program_application_id
	    ,stu_rec.program_id
	    ,stu_rec.program_update_date
	    ,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.multiple_occurences_flag
	    );
Line: 3836

	l_null_return     varchar2(1);	-- used for 'select null' statements
Line: 3838

	CURSOR stu			-- Selects all rows from startup entity
	IS
	    select field_name
	    ,      legislation_code
	    ,      prompt
	    ,      validation_name
	    ,      validation_type
	    ,	   target_location
            ,      rule_mode
            ,      rule_type
            ,      PROMPT_MESSAGE
            ,      IN_LINE_MESSAGE
            ,      QUICK_TIP_MESSAGE
            ,      BUBBLE_TIP_MESSAGE
            ,      category
	    ,      rowid
	    from   hr_s_legislative_field_info;
Line: 3856

    stu_rec stu%ROWTYPE;			-- Record for the above select
Line: 3863

	delete from hr_s_legislative_field_info
	where  rowid = stu_rec.rowid;
Line: 3871

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

	l_prompt    pay_legislative_field_info.prompt%type;
Line: 3887

	select prompt
	,      validation_type
        ,      rule_mode
        ,      PROMPT_MESSAGE
        ,      IN_LINE_MESSAGE
        ,      QUICK_TIP_MESSAGE
        ,      BUBBLE_TIP_MESSAGE
        ,      category
        ,      target_location
        ,      rowid
	into   l_prompt
	,      l_val_type
        ,      l_rule_mode
        ,      l_PROMPT_MESSAGE
        ,      l_IN_LINE_MESSAGE
        ,      l_QUICK_TIP_MESSAGE
        ,      l_BUBBLE_TIP_MESSAGE
        ,      l_category
        ,      l_target_location
        ,      l_rowid
	from   pay_legislative_field_info
	where  field_name = stu_rec.field_name
	and    legislation_code = stu_rec.legislation_code
        and    rule_type = stu_rec.rule_type
        and    nvl(target_location,'~') = nvl(stu_rec.target_location,'~')
        and    nvl(validation_name,'~') = nvl(stu_rec.validation_name,'~');
Line: 3944

	    update pay_legislative_field_info
	    set
	           prompt = stu_rec.prompt
	    ,      validation_name    = stu_rec.validation_name
	    ,      validation_type    = stu_rec.validation_type
            ,      target_location    = stu_rec.target_location
            ,      rule_mode          = stu_rec.rule_mode
            ,      PROMPT_MESSAGE     = stu_rec.PROMPT_MESSAGE
            ,      IN_LINE_MESSAGE    = stu_rec.IN_LINE_MESSAGE
            ,      QUICK_TIP_MESSAGE  = stu_rec.QUICK_TIP_MESSAGE
            ,      BUBBLE_TIP_MESSAGE = stu_rec.BUBBLE_TIP_MESSAGE
            ,      CATEGORY           = stu_rec.CATEGORY
            where  rowid = l_rowid;
Line: 3964

	    -- Row needs to be inserted

	    IF phase = 1 THEN return; END IF;
Line: 3970

	    insert into pay_legislative_field_info
	    (field_name
	    ,legislation_code
	    ,prompt
	    ,validation_name
	    ,validation_type
            ,target_location
            ,rule_mode
            ,rule_type
            ,PROMPT_MESSAGE
            ,IN_LINE_MESSAGE
            ,QUICK_TIP_MESSAGE
            ,BUBBLE_TIP_MESSAGE
            ,CATEGORY
	    )
	    values
	    (stu_rec.field_name
	    ,stu_rec.legislation_code
	    ,stu_rec.prompt
	    ,stu_rec.validation_name
	    ,stu_rec.validation_type
	    ,stu_rec.target_location
            ,stu_rec.rule_mode
            ,stu_rec.rule_type
            ,stu_rec.PROMPT_MESSAGE
            ,stu_rec.IN_LINE_MESSAGE
            ,stu_rec.QUICK_TIP_MESSAGE
            ,stu_rec.BUBBLE_TIP_MESSAGE
            ,stu_rec.CATEGORY
	    );
Line: 4040

    l_null_return varchar2(1);	 	-- Used for 'select null' statements
Line: 4045

	select payment_type_id c_surrogate_key
	,      territory_code
	,      currency_code
	,      category
	,      payment_type_name c_true_key
	,      allow_as_default
	,      description
	,      pre_validation_required
	,      procedure_name
	,      validation_days
	,      validation_value
	,      last_update_date
	,      last_updated_by
	,      last_update_login
	,      created_by
	,      creation_date
	,      rowid
	from   hr_s_payment_types;
Line: 4064

    stu_rec stu%ROWTYPE;			-- Record for above SELECT
Line: 4078

	-- 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 count(*)
            into cnt
            from hr_s_payment_types;
Line: 4107

	    select distinct null
	    into   l_null_return
	    from   pay_payment_types a
	    where  exists
		(select null
		 from   hr_s_payment_types b
		 where  a.payment_type_id = b.payment_type_id
		);
Line: 4117

	    --update all payment_type_id's to remove conflict

	    update /*+NO_INDEX*/  hr_s_payment_types
	    set    payment_type_id = payment_type_id - 50000000;
Line: 4122

	    update hr_s_application_ownerships
	    set    key_value = key_value - 50000000
	    where  key_name = 'PAYMENT_TYPE_ID';
Line: 4130

	select min(payment_type_id) - (count(*) *3)
	,      max(payment_type_id) + (count(*) *3)
	into   v_min_delivered
	,      v_max_delivered
	from   hr_s_payment_types;
Line: 4136

        select max(payment_type_id)
        into   v_max_live
        from   pay_payment_types;
Line: 4140

	select pay_payment_types_s.nextval
	into   v_sequence_number
	from   dual;
Line: 4176

        insert_hr_stu_exceptions ('pay_payment_types'
        ,      stu_rec.c_surrogate_key
        ,      exception_type
        ,      stu_rec.c_true_key);
Line: 4184

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

    BEGIN

	BEGIN

	    select distinct payment_type_id
	    into   l_new_surrogate_key
	    from   pay_payment_types
	    where  payment_type_name = stu_rec.c_true_key
            and     ((territory_code is NULL and stu_rec.territory_code is NULL)
                      or stu_rec.territory_code= territory_code);
Line: 4203

	    select pay_payment_types_s.nextval
	    into   l_new_surrogate_key
	    from   dual;
Line: 4208

	-- Update all child entities


	update hr_s_payment_types
	set    payment_type_id = l_new_surrogate_key
	where  payment_type_id = stu_rec.c_surrogate_key;
Line: 4215

	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 = 'PAYMENT_TYPE_ID';
Line: 4219

    END update_uid;
Line: 4228

	delete from hr_s_payment_types
	where  rowid = stu_rec.rowid;
Line: 4237

	-- Check if a delivered row is needed and insert into the
	-- live tables if it is.
	--
	-- #310520. Change to update the row if it already exists. This
	-- differs from the previous functionality, which only ever did
	-- inserts, and wouldn't handle updates.
	--
    BEGIN
	IF p_phase = 1 THEN
	    return;
Line: 4249

	update	pay_payment_types
	set	payment_type_id		= stu_rec.c_surrogate_key
	,	currency_code		= stu_rec.currency_code
	,	category		= stu_rec.category
	,	allow_as_default	= stu_rec.allow_as_default
	,	description		= stu_rec.description
	,	pre_validation_required	= stu_rec.pre_validation_required
	,	procedure_name		= stu_rec.procedure_name
	,	validation_days		= stu_rec.validation_days
	,	validation_value	= stu_rec.validation_value
	,	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	payment_type_name	= stu_rec.c_true_key
        and     ((territory_code is NULL and stu_rec.territory_code is NULL)
                 or stu_rec.territory_code= territory_code);
Line: 4272

	    insert into pay_payment_types
	    (payment_type_id
	    ,territory_code
	    ,currency_code
	    ,category
	    ,payment_type_name
	    ,allow_as_default
	    ,description
	    ,pre_validation_required
	    ,procedure_name
	    ,validation_days
	    ,validation_value
	    ,last_update_date
	    ,last_updated_by
	    ,last_update_login
	    ,created_by
	    ,creation_date
	    )
	    values
	    (stu_rec.c_surrogate_key
	    ,stu_rec.territory_code
	    ,stu_rec.currency_code
	    ,stu_rec.category
	    ,stu_rec.c_true_key
	    ,stu_rec.allow_as_default
	    ,stu_rec.description
	    ,stu_rec.pre_validation_required
	    ,stu_rec.procedure_name
	    ,stu_rec.validation_days
	    ,stu_rec.validation_value
	    ,stu_rec.last_update_date
	    ,stu_rec.last_updated_by
	    ,stu_rec.last_update_login
	    ,stu_rec.created_by
	    ,stu_rec.creation_date
	    );
Line: 4347

	IF p_phase = 1 THEN update_uid; END IF;
Line: 4373

	select r1.effective_start_date
	,      r1.user_row_id c_surrogate_key
	,      r1.row_low_range_or_name c_true_key
	,      r1.row_high_range
	,      r1.legislation_code
	,      r1.legislation_subgroup
	,      r1.user_table_id
        from   hr_s_user_rows_f r1
        where  not exists(
               select null
               from hr_s_user_rows_f r2
               where r2.user_row_id = r1.user_row_id
               and r2.effective_start_date < r1.effective_start_date);
Line: 4389

	-- 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_user_rows_f
	where  user_row_id = pc_user_row_id;
Line: 4399

	-- select all child user column instances for the current user row

	select *
	from   hr_s_user_column_instances_f
	where  user_row_id = p_user_row_id;
Line: 4420

	-- 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 count(*)
            into cnt
            from hr_s_user_rows_f;
Line: 4449

	    select distinct null
	    into   l_null_return
	    from   pay_user_rows_f a
	    where  exists
		(select null
		 from   hr_s_user_rows_f b
		 where  a.user_row_id = b.user_row_id
		);
Line: 4459

	    --update all user_row_id's to remove conflict

	    update /*+NO_INDEX*/ hr_s_user_rows_f
	    set    user_row_id = user_row_id - 50000000;
Line: 4464

            update /*+NO_INDEX*/ hr_s_user_column_instances_f
            set    user_row_id = user_row_id - 50000000;
Line: 4467

	    update hr_s_application_ownerships
	    set    key_value = key_value - 50000000
	    where  key_name = 'USER_ROW_ID';
Line: 4477

	select min(user_row_id) - (count(*) *3)
	,      max(user_row_id) + (count(*) *3)
	into   v_min_delivered
	,      v_max_delivered
	from   hr_s_user_rows_f;
Line: 4483

        select max(user_row_id)
        into   v_max_live
        from   pay_user_rows_f;
Line: 4487

	select pay_user_rows_s.nextval
	into   v_sequence_number
	from   dual;
Line: 4523

 	insert_hr_stu_exceptions('pay_user_rows_f'
	,      r_distinct.c_surrogate_key
        ,      exception_type
        ,      r_distinct.c_true_key);
Line: 4534

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

    BEGIN

	delete from hr_s_user_rows_f
	where  user_row_id = v_id;
Line: 4542

	delete from hr_s_user_column_instances_f
	where  user_row_id = v_id;
Line: 4547

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

    BEGIN

	-- See if this primary key is already installed. If so then the sorrogate
	-- 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 user_row_id
          into   l_new_user_row_id
          from   pay_user_rows_f
          where  user_table_id         = r_distinct.user_table_id
          and    row_low_range_or_name = r_distinct.c_true_key
          and    nvl(row_high_range, 'NULL') =
                    nvl(r_distinct.row_high_range, 'NULL')
          and    effective_start_date  = r_distinct.effective_start_date
          and    business_Group_id is null
          and    nvl(legislation_code, 'x') = nvl(r_distinct.legislation_code, 'x');
Line: 4577

	    select pay_user_rows_s.nextval
	    into   l_new_user_row_id
	    from   dual;
Line: 4592

	update hr_s_user_rows_f
	set    user_row_id = l_new_user_row_id
	where  user_row_id = r_distinct.c_surrogate_key;
Line: 4597

	update hr_s_application_ownerships
	set    key_value = to_char(l_new_user_row_id)
	where  key_value = to_char(r_distinct.c_surrogate_key)
	and    key_name = 'USER_ROW_ID';
Line: 4603

	update hr_s_user_column_instances_f
	set    user_row_id = l_new_user_row_id
	where  user_row_id = r_distinct.c_surrogate_key;
Line: 4607

    END update_uid;
Line: 4623

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

	-- If a row is found 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
	    -- Check first parent does not exist in the delivery tables

	    select null
	    into   l_null_return
	    from   hr_s_user_tables
	    where  user_table_id = r_each_row.user_table_id;
Line: 4657

	    select null
	    into   l_null_return
	    from   pay_user_tables
	    where  user_table_id = r_each_row.user_table_id;
Line: 4702

	    -- Add the user table id and row high range to the select criteria.
	    --
	    -- Further fix necessary to cater for the possibility that the
	    -- high range may be null. Must put NVL on both sides, otherwise
	    -- matching rows with null row_high_ranges are not detected.
	    --
            select distinct null
            into   l_null_return
            from  pay_user_rows_f a
            where a.user_table_id = r_distinct.user_table_id
            and   a.effective_start_date  = r_distinct.effective_start_date
            and   a.row_low_range_or_name = r_distinct.c_true_key
            and    nvl(row_high_range, 'NULL') =
                    nvl(r_distinct.row_high_range, 'NULL')
            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(r_distinct.legislation_code,b.legislation_code));
Line: 4740

	    -- Add the user table id and row high range to the select criteria.
	    --
	    --
	    -- Further fix necessary to cater for the possibility that the
	    -- high range may be null. Must put NVL on both sides, otherwise
	    -- matching rows with null row_high_ranges are not detected.
	    --
	    select distinct null
	    into   l_null_return
	    from   pay_user_rows_f
	    where  row_low_range_or_name = r_distinct.c_true_key
            and    effective_start_date  = r_distinct.effective_start_date
            and    nvl(row_high_range, 'NULL') =
                    nvl(r_distinct.row_high_range, 'NULL')
	    and    user_table_id         = r_distinct.user_table_id
	    and    nvl(legislation_code,'x') <>
                                       nvl(r_distinct.legislation_code,'x')
	    and   (
	           legislation_code is null
	        or r_distinct.legislation_code is null
	          );
Line: 4773

	-- 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.

	-- 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 return TRUE; END IF;
Line: 4793

        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 = 'USER_ROW_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: 4809

        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 = 'USER_ROW_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: 4888

		    -- Get new surrogate id and update child references

		    update_uid;
Line: 4895

		    delete from pay_user_column_instances_f
		    where  user_row_id = r_distinct.c_surrogate_key
		    and    business_group_id is null;
Line: 4899

		    delete from pay_user_rows_f
		    where  user_row_id = r_distinct.c_surrogate_key;
Line: 4908

			insert into pay_user_rows_f
			(user_row_id
			,effective_start_date
			,effective_end_date
			,business_group_id
			,legislation_code
			,user_table_id
			,row_low_range_or_name
			,display_sequence
			,legislation_subgroup
			,row_high_range
			,last_update_date
			,last_updated_by
			,last_update_login
			,created_by
			,creation_date
			)
			values
			(each_row.user_row_id
			,each_row.effective_start_date
			,each_row.effective_end_date
			,each_row.business_group_id
			,each_row.legislation_code
			,each_row.user_table_id
			,each_row.row_low_range_or_name
			,each_row.display_sequence
			,each_row.legislation_subgroup
			,each_row.row_high_range
			,each_row.last_update_date
			,each_row.last_updated_by
			,each_row.last_update_login
			,each_row.created_by
			,each_row.creation_date
			);
Line: 4965

				    select distinct null
				    into   l_null_return
				    from   pay_user_columns
				    where  user_column_id = each_child.user_column_id;
Line: 4970

				    insert into pay_user_column_instances_f
				    (user_column_instance_id
				    ,effective_start_date
				    ,effective_end_date
				    ,user_row_id
				    ,user_column_id
				    ,business_group_id
				    ,legislation_code
				    ,legislation_subgroup
				    ,value
				    ,last_update_date
				    ,last_updated_by
				    ,last_update_login
				    ,created_by
				    ,creation_date)
				    select pay_user_column_instances_s.nextval
				    ,each_child.effective_start_date
				    ,each_child.effective_end_date
				    ,each_child.user_row_id
				    ,each_child.user_column_id
				    ,each_child.business_group_id
				    ,each_child.legislation_code
				    ,each_child.legislation_subgroup
				    ,each_child.value
				    ,each_child.last_update_date
				    ,each_child.last_updated_by
				    ,each_child.last_update_login
				    ,each_child.created_by
				    ,each_child.creation_date
				    from dual;
Line: 5049

		-- is within the correct range, rows will be inserted/updated to the
		-- history table. If the routine has been called in pahse 2, a row must
		-- exist in the history table.

		cursor c_legs is
		  select package_name
		  from   hr_s_history;
Line: 5061

		-- First insert a row into the hr_stu_history table

		FOR r_legs in c_legs loop

		  v_package_name := r_legs.package_name;
Line: 5069

		    delete from hr_stu_exceptions;
Line: 5082

		    update hr_stu_history
		    set    status = 'Phase '||p_phase
		    where  package_name = v_package_name;
Line: 5090

			insert into hr_stu_history
			(package_name
			,date_of_export
			,date_of_import
			,status
			,legislation_code
			)
			select distinct package_name
			,      date_of_export
			,      sysdate
			,      'Phase 1'
			,      legislation_code
			from   hr_s_history
			where package_name = v_package_name;
Line: 5125

		l_null_return varchar2(1); 	-- Used for 'select null' statements
Line: 5130

		select monetary_unit_id c_surrogate_key
		,      currency_code
		,      business_group_id
		,      legislation_code c_leg_code
		,      monetary_unit_name c_true_key
		,      relative_value
		,      last_update_date
		,      last_updated_by
		,      last_update_login
		,      created_by
		,      creation_date
		,      rowid
		from   hr_s_monetary_units;
Line: 5144

	    stu_rec	stu%ROWTYPE;		-- Record definition for above SELECT
Line: 5158

		insert_hr_stu_exceptions('PAY_MONETARY_UNITS'
		,      stu_rec.c_surrogate_key
		,      exception_type
		,      stu_rec.c_true_key);
Line: 5177

		-- 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 count(*)
       		     into cnt
       		     from hr_s_monetary_units;
Line: 5206

		    select distinct null
		    into   l_null_return
		    from   pay_monetary_units a
		    where  exists
			(select null
			 from   hr_s_monetary_units b
			 where  a.monetary_unit_id = b.monetary_unit_id
			);
Line: 5216

		    --update all monetary_unit_id's to remove conflict

		    update hr_s_monetary_units
		    set    monetary_unit_id = monetary_unit_id - 50000000;
Line: 5221

		    update hr_s_application_ownerships
		    set    key_value = key_value - 50000000
		    where  key_name = 'MONETARY_UNIT_ID';
Line: 5230

		select min(monetary_unit_id) - (count(*) *3)
		,      max(monetary_unit_id) + (count(*) *3)
		into   v_min_delivered
		,      v_max_delivered
		from   hr_s_monetary_units;
Line: 5236

                select max(monetary_unit_id)
                into   v_max_live
                from   pay_monetary_units;
Line: 5240

		select pay_monetary_units_s.nextval
		into   v_sequence_number
		from   dual;
Line: 5262

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

	    BEGIN

		BEGIN
		    select distinct monetary_unit_id
		    into   l_new_surrogate_key
		    from   pay_monetary_units
		    where  currency_code = stu_rec.currency_code
		    and    monetary_unit_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: 5284

		    select pay_monetary_units_s.nextval
			    into   l_new_surrogate_key
			    from   dual;
Line: 5290

		-- Update all child entities


		update hr_s_monetary_units
		set    monetary_unit_id = l_new_surrogate_key
		where  monetary_unit_id = stu_rec.c_surrogate_key;
Line: 5297

		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 = 'MONETARY_UNIT_ID';
Line: 5302

	    END update_uid;
Line: 5311

		delete from hr_s_monetary_units
		where  rowid = stu_rec.rowid;
Line: 5328

		-- 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.


		IF p_phase <> 1 THEN return TRUE; END IF;
Line: 5350

		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 = 'MONETARY_UNIT_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: 5380

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

		-- The procedure checks to see if the same monetary unit has been
		-- installed in a contentious business group or legislation.

	    BEGIN

		BEGIN

		    -- Perform a check to see if the primary key has been creeated 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_monetary_units a
                    where a.monetary_unit_name = stu_rec.c_true_key
                    and    a.currency_code = stu_rec.currency_code
                    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: 5423

		    select distinct null
		    into   l_null_return
		    from   pay_monetary_units
		    where  monetary_unit_name = stu_rec.c_true_key
		    and    currency_code = stu_rec.currency_code
		    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: 5450

		IF p_phase = 1 THEN return; END IF;  --only insert on phase 2
Line: 5452

		-- 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.


		update pay_monetary_units
		set    currency_code = stu_rec.currency_code
		,      business_group_id = null
		,      legislation_code = stu_rec.c_leg_code
		,      relative_value = stu_rec.relative_value
		,      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  monetary_unit_id = stu_rec.c_surrogate_key;
Line: 5486

		    insert into pay_monetary_units
		    (monetary_unit_id
		    ,currency_code
		    ,business_group_id
		    ,legislation_code
		    ,monetary_unit_name
		    ,relative_value
		    ,last_update_date
		    ,last_updated_by
		    ,last_update_login
		    ,created_by
		    ,creation_date
		    )
		    values
		    (stu_rec.c_surrogate_key
		    ,stu_rec.currency_code
		    ,stu_rec.business_group_id
		    ,stu_rec.c_leg_code
		    ,stu_rec.c_true_key
		    ,stu_rec.relative_value
		    ,stu_rec.last_update_date
		    ,stu_rec.last_updated_by
		    ,stu_rec.last_update_login
		    ,stu_rec.created_by
		    ,stu_rec.creation_date
		    );
Line: 5529

	    -- if the row is required then the surrogate id is updated and the
	    -- main transfer logic is called.

	    IF p_phase = 1 THEN check_next_sequence; END IF;
Line: 5545

		    IF p_phase = 1 THEN update_uid; END IF;
Line: 5565

	   l_null_return varchar2(1);                  -- used for 'select null' statements
Line: 5568

	    CURSOR stu                          -- Selects all rows from startup entity
	    IS
		select   report_type            ,
			 report_qualifier       ,
			 report_format          ,
			 effective_start_date   ,
			 effective_end_date     ,
			 range_code             ,
			 assignment_action_code ,
			 initialization_code    ,
			 archive_code           ,
			 magnetic_code          ,
			 report_category        ,
			 report_name            ,
			 sort_code              ,
			 updatable_flag         ,
                         deinitialization_code  ,
			 last_update_date       ,
			 last_updated_by        ,
			 last_update_login      ,
			 created_by             ,
			 creation_date          ,
                         temporary_action_flag  ,
			 rowid
		from hr_s_report_format_mappings_f;
Line: 5603

		delete from hr_s_report_format_mappings_f
		where  rowid = stu_rec.rowid;
Line: 5615

		-- this updates uses only report_type,qualifier,category as its primary key
		-- it may be that effective start and end dates will need to be added
		-- but as of know we can see no need for this

		update pay_report_format_mappings_f
		set  effective_start_date=stu_rec.effective_start_date
		,    effective_end_date=stu_rec.effective_end_date
		,    range_code=stu_rec.range_code
		,    assignment_action_code=stu_rec.assignment_action_code
		,    initialization_code=stu_rec.initialization_code
		,    archive_code=stu_rec.archive_code
		,    magnetic_code=stu_rec.magnetic_code
		,    report_name=stu_rec.report_name
		,    sort_code=stu_rec.sort_code
		,    updatable_flag=stu_rec.updatable_flag
		,    report_format=stu_rec.report_format
                ,    deinitialization_code=stu_rec.deinitialization_code
                ,    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
                ,    temporary_action_flag = stu_rec.temporary_action_flag
		where report_type= stu_rec.report_type
		and   report_qualifier=stu_rec.report_qualifier
		and   report_category=stu_rec.report_category
		and   effective_start_date = stu_rec.effective_start_date
		and   effective_end_date = stu_rec.effective_end_date;
Line: 5647

		    insert into pay_report_format_mappings_f
		    ( report_type            ,
		      report_qualifier       ,
		      report_format          ,
		      effective_start_date   ,
		      effective_end_date     ,
		      range_code             ,
		      assignment_action_code ,
		      initialization_code    ,
		      archive_code           ,
		      magnetic_code          ,
		      report_category        ,
		      report_name            ,
		      sort_code              ,
		      updatable_flag         ,
                      deinitialization_code  ,
                      last_update_date       ,
                      last_updated_by        ,
                      last_update_login      ,
                      created_by             ,
                      creation_date          ,
                      temporary_action_flag
		    )
		    values
		    ( stu_rec.report_type            ,
		      stu_rec.report_qualifier       ,
		      stu_rec.report_format          ,
		      stu_rec.effective_start_date   ,
		      stu_rec.effective_end_date     ,
		      stu_rec.range_code             ,
		      stu_rec.assignment_action_code ,
		      stu_rec.initialization_code    ,
		      stu_rec.archive_code           ,
		      stu_rec.magnetic_code          ,
		      stu_rec.report_category        ,
		      stu_rec.report_name            ,
		      stu_rec.sort_code              ,
		      stu_rec.updatable_flag         ,
                      stu_rec.deinitialization_code  ,
                      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.temporary_action_flag
		    );
Line: 5728

	   l_null_return varchar2(1);                  -- used for 'select null' statements
Line: 5733

	    CURSOR stu                          -- Selects all rows from startup entity
	    IS
		select  distinct magnetic_block_id  	c_surrogate_key,
			block_name		c_true_key,
			main_block_flag,
			report_format,
			cursor_name,
			no_column_returned
		from hr_s_magnetic_blocks;
Line: 5762

	            select count(*)
	            into cnt
       		    from hr_s_magnetic_blocks;
Line: 5768

		    select distinct null
		    into   l_null_return
		    from   pay_magnetic_blocks a
		    where  exists
			(select null
			 from   hr_s_magnetic_blocks b
			 where  a.magnetic_block_id = b.magnetic_block_id
			);
Line: 5777

		    update hr_s_magnetic_blocks
		    set magnetic_block_id=magnetic_block_id -50000000;
Line: 5780

		    update hr_s_magnetic_records
		    set magnetic_block_id=magnetic_block_id -50000000;
Line: 5783

		    update hr_s_magnetic_records
		    set next_block_id=next_block_id -50000000;
Line: 5791

		select min(magnetic_block_id) - (count(*) *3)
		,      max(magnetic_block_id) + (count(*) *3)
		into   v_min_delivered
		,      v_max_delivered
		from   hr_s_magnetic_blocks;
Line: 5797

                select max(magnetic_block_id)
                into   v_max_live
                from   pay_magnetic_blocks;
Line: 5801

		select pay_magnetic_blocks_s.nextval
		into   v_sequence_number
		from   dual;
Line: 5836

		insert_hr_stu_exceptions('pay_magnetic_blocks'
		    ,      stu_rec.c_surrogate_key
		    ,      exception_type
		    ,      stu_rec.c_true_key);
Line: 5847

	    PROCEDURE update_uid
	    --------------------
	    IS

	    BEGIN


		BEGIN

                    select distinct magnetic_block_id
		    into   l_new_surrogate_key
		    from   pay_magnetic_blocks
		    where  replace(ltrim(rtrim(upper(block_name))), ' ', '_') =
			   replace(ltrim(rtrim(upper(stu_rec.c_true_key))), ' ', '_')
		    and    replace(ltrim(rtrim(upper(report_format))), ' ', '_') =
			   replace(ltrim(rtrim(upper(stu_rec.report_format))), ' ', '_')
		    and    replace(ltrim(rtrim(upper(nvl(cursor_name,'X')))), ' ', '_') =
			   replace(ltrim(rtrim(upper(nvl(stu_rec.cursor_name,'X')))), ' ', '_');
Line: 5868

		    select pay_magnetic_blocks_s.nextval
		    into l_new_surrogate_key
		    from   dual;
Line: 5885

		-- Update all child entities

		update hr_s_magnetic_blocks
		set	magnetic_block_id = l_new_surrogate_key
		where   magnetic_block_id = stu_rec.c_surrogate_key;
Line: 5891

		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 = 'MAGNETIC_BLOCK_ID';
Line: 5896

		update hr_s_magnetic_records
		set  magnetic_block_id = l_new_surrogate_key
		where   magnetic_block_id = stu_rec.c_surrogate_key;
Line: 5900

		update hr_s_magnetic_records
		set  next_block_id= l_new_surrogate_key
		where   next_block_id=stu_rec.c_surrogate_key;
Line: 5904

	    END update_uid;
Line: 5913

	      delete from hr_s_magnetic_blocks
	      where  magnetic_block_id = stu_rec.c_surrogate_key;
Line: 5921

	    -- if a magnetic_block has changed then the row will be updated,
	    -- if it is new , it gets inserted.

	    IS

	    BEGIN


		BEGIN
		    select distinct null
		    into   l_null_return
		    from   pay_magnetic_blocks
		    where  magnetic_block_id =l_new_surrogate_key
		    and    block_name = stu_rec.c_true_key
		    and    main_block_flag =stu_rec.main_block_flag
		    and    report_format =stu_rec.report_format
		    and    nvl(cursor_name,'')=nvl(stu_rec.cursor_name,'')
		    and    nvl(no_column_returned,0)=nvl(stu_rec.no_column_returned,0);
Line: 5944

		    update pay_magnetic_blocks
		    set block_name=stu_rec.c_true_key
		    ,	main_block_flag=stu_rec.main_block_flag
		    ,	report_format=stu_rec.report_format
		    ,	cursor_name=stu_rec.cursor_name
		    ,	no_column_returned=stu_rec.no_column_returned
		    where magnetic_block_id =stu_rec.c_surrogate_key;
Line: 5954

			-- No row there to update, must insert

                       BEGIN
			insert into pay_magnetic_blocks
			 ( magnetic_block_id  ,
			   block_name         ,
			   main_block_flag    ,
			   report_format      ,
			   cursor_name        ,
			   no_column_returned)
			values
			( stu_rec.c_surrogate_key    ,
			  stu_rec.c_true_key         ,
			  stu_rec.main_block_flag    ,
			  stu_rec.report_format      ,
			  stu_rec.cursor_name        ,
			  stu_rec.no_column_returned);
Line: 6000

		IF p_phase = 1 THEN update_uid; END IF;
Line: 6011

	    l_null_return varchar2(1);                  -- used for 'select null' statements
Line: 6014

	    CURSOR stu                          -- Selects all rows from startup entity
	    IS
		select distinct
		     formula_id           ,
		     magnetic_block_id    ,
		     next_block_id        ,
		     overflow_mode        ,
		     sequence             ,
		     frequency            ,
		     last_run_executed_mode
		from hr_s_magnetic_records;
Line: 6034

	      delete from hr_s_magnetic_records
	      where  magnetic_block_id = stu_rec.magnetic_block_id
              and    sequence = stu_rec.sequence;
Line: 6048

		    select distinct null
		    into   l_null_return
		    from   pay_magnetic_records
		    where  formula_id=stu_rec.formula_id
		    and	   magnetic_block_id=stu_rec.magnetic_block_id
		    and    next_block_id=stu_rec.next_block_id
		    and    overflow_mode=stu_rec.overflow_mode
		    and    sequence=stu_rec.sequence
		    and    frequency=stu_rec.frequency
		    and    last_run_executed_mode=stu_rec.last_run_executed_mode;
Line: 6063

		    update pay_magnetic_records
		    set formula_id=stu_rec.formula_id
		    ,	next_block_id=stu_rec.next_block_id
		    ,   overflow_mode=stu_rec.overflow_mode
		    ,   frequency=stu_rec.frequency
		    ,   last_run_executed_mode=stu_rec.last_run_executed_mode
		    where magnetic_block_id=stu_rec.magnetic_block_id
		    and   sequence=stu_rec.sequence;
Line: 6075

			-- No row there to update, must insert


                     BEGIN
			insert into pay_magnetic_records
			 ( formula_id           ,
			   magnetic_block_id    ,
			   next_block_id        ,
			   overflow_mode        ,
			   sequence             ,
			   frequency            ,
			   last_run_executed_mode)
			 values
			 ( stu_rec.formula_id           ,
			   stu_rec.magnetic_block_id    ,
			   stu_rec.next_block_id        ,
			   stu_rec.overflow_mode        ,
			   stu_rec.sequence             ,
			   stu_rec.frequency            ,
			   stu_rec.last_run_executed_mode);
Line: 6135

	   l_null_return varchar2(1);                  -- used for 'select null' statements
Line: 6140

	    CURSOR stu                          -- Selects all rows from startup entity
	    IS
		select   report_type            ,
			 report_qualifier       ,
			 report_category        ,
			 user_entity_id		,
			 effective_start_date	,
			 effective_end_date	,
			 archive_type		,
			 updatable_flag		,
			 display_sequence	,
			 report_format_item_id  c_surrogate_key,
			 last_update_date       ,
			 last_updated_by        ,
			 last_update_login      ,
			 created_by             ,
			 creation_date          ,
                 rowid
        from hr_s_report_format_items_f;
Line: 6180

	            select count(*)
	            into cnt
       		    from  hr_s_report_format_items_f;
Line: 6186

		    select distinct null
		    into   l_null_return
		    from   pay_report_format_items_f a
		    where  exists
			(select null
			 from   hr_s_report_format_items_f b
			 where  a.report_format_item_id = b.report_format_item_id
			);
Line: 6195

		    update hr_s_report_format_items_f
		    set report_format_item_id=report_format_item_id -50000000;
Line: 6203

		select min(report_format_item_id) - (count(*) *3)
		,      max(report_format_item_id) + (count(*) *3)
		into   v_min_delivered
		,      v_max_delivered
		from   hr_s_report_format_items_f;
Line: 6209

                select max(report_format_item_id)
                into   v_max_live
                from   pay_report_format_items_f;
Line: 6213

		select pay_report_format_items_s.nextval
		into   v_sequence_number
		from   dual;
Line: 6236

PROCEDURE update_uid
	    --------------------
	    IS

	    BEGIN


		BEGIN

                    select distinct report_format_item_id
		    into   l_new_surrogate_key
		    from   pay_report_format_items_f
		    where  report_type = stu_rec.report_type
		    and    report_qualifier = stu_rec.report_qualifier
		    and    report_category  = stu_rec.report_category
		    and    user_entity_id = stu_rec.user_entity_id;
Line: 6256

		    select pay_report_format_items_s.nextval
		    into l_new_surrogate_key
		    from   dual;
Line: 6277

		     select pay_report_format_items_s.nextval
		     into l_new_surrogate_key
		     from   dual;
Line: 6283

		update hr_s_report_format_items_f
		set	report_format_item_id = l_new_surrogate_key
		where   report_type = stu_rec.report_type
		  and   report_qualifier = stu_rec.report_qualifier
		  and   report_category  = stu_rec.report_category
		  and   user_entity_id = stu_rec.user_entity_id;
Line: 6290

	    END update_uid;
Line: 6299

        delete from hr_s_report_format_items_f
        where  rowid = stu_rec.rowid;
Line: 6315

        update pay_report_format_items_f
        set  effective_start_date=stu_rec.effective_start_date
        ,    effective_end_date=stu_rec.effective_end_date
        ,    archive_type=stu_rec.archive_type
        ,    updatable_flag=stu_rec.updatable_flag
        ,    display_sequence=stu_rec.display_sequence
        ,    report_format_item_id = stu_rec.c_surrogate_key
        ,    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 report_type= stu_rec.report_type
        and   report_qualifier=stu_rec.report_qualifier
        and   report_category=stu_rec.report_category
	and   user_entity_id=stu_rec.user_entity_id
	and   effective_start_date = stu_rec.effective_start_date
	and   effective_end_date = stu_rec.effective_end_date ;
Line: 6336

            insert into pay_report_format_items_f
            ( report_type            ,
              report_qualifier       ,
              report_category        ,
	      user_entity_id	     ,
              effective_start_date   ,
              effective_end_date     ,
              archive_type           ,
              updatable_flag	     ,
	      display_sequence       ,
	      report_format_item_id  ,
              last_update_date       ,
	      last_updated_by        ,
	      last_update_login      ,
	      created_by             ,
	      creation_date
            )
            values
            ( stu_rec.report_type            ,
              stu_rec.report_qualifier       ,
              stu_rec.report_category        ,
	      stu_rec.user_entity_id	     ,
              stu_rec.effective_start_date   ,
              stu_rec.effective_end_date     ,
              stu_rec.archive_type           ,
              stu_rec.updatable_flag         ,
	      stu_rec.display_sequence       ,
              stu_rec.c_surrogate_key        ,
              stu_rec.last_update_date       ,
	      stu_rec.last_updated_by        ,
	      stu_rec.last_update_login      ,
	      stu_rec.created_by             ,
	      stu_rec.creation_date
            );
Line: 6403

        IF p_phase = 1 THEN update_uid; END IF;
Line: 6566

	select count(*)
	into   v_exception_counter
	from   hr_stu_exceptions;
Line: 6574

	    update hr_stu_history
	    set    status = 'Phase '||p_phase||' has exceptions raised'
	    where  package_name in
	           (select package_name
		   from   hr_s_history);
Line: 6586

		update hr_stu_history a
		set    a.status = 'Complete'
		where  exists
			(select null
			 from   hr_s_history b
			 where  b.package_name = a.package_name
			 and    b.date_of_export = a.date_of_export
			);
Line: 6636

            select
              BT.BALANCE_TYPE_ID,
              L.LANGUAGE_CODE TRANS_LANG,
              B.LANGUAGE_CODE BASE_LANG,
              BT.BALANCE_NAME,
              BT.REPORTING_NAME,
              BT.LAST_UPDATE_DATE,
              BT.LAST_UPDATED_BY,
              BT.LAST_UPDATE_LOGIN,
              BT.CREATED_BY,
              BT.CREATION_DATE
            from PAY_BALANCE_TYPES BT,
              FND_LANGUAGES L,
              FND_LANGUAGES B
            where L.INSTALLED_FLAG in ('I', 'B')
              and B.INSTALLED_FLAG = 'B'
              and NVL(TO_CHAR(BT.BUSINESS_GROUP_ID),'Null Value')='Null Value'
              and (
                  not exists (
                      select '1'
                        from pay_balance_types_tl btt
                        where btt.balance_type_id = bt.balance_type_id
                        and btt.language = l.language_code)
               or exists (select '1' from pay_balance_types_tl btt2
                          where btt2.balance_type_id = bt.balance_type_id
                          and   btt2.language = b.language_code
                          and   nvl(btt2.reporting_name,'XXX') <>
                                 nvl(bt.reporting_name,'XXX'))
              );
Line: 6677

            delete PAY_BALANCE_TYPES_TL
            where rowid in (select pbttl.rowid
             from pay_balance_types pbt,
                  pay_balance_types_tl pbttl
             where pbt.balance_type_id = pbttl.balance_type_id
             and nvl(pbt.reporting_name, 'XXX') <>
                 nvl(pbttl.reporting_name, 'XXX')
             and NVL(TO_CHAR(PBT.BUSINESS_GROUP_ID),'Null Value')='Null Value'
             and pbttl.BALANCE_TYPE_ID = l_rec.BALANCE_TYPE_ID
             and pbttl.language = l_rec.trans_lang);
Line: 6690

            insert into PAY_BALANCE_TYPES_TL
            (
              BALANCE_TYPE_ID,
              LANGUAGE,
              SOURCE_LANG,
              BALANCE_NAME,
              REPORTING_NAME,
              LAST_UPDATE_DATE,
              LAST_UPDATED_BY,
              LAST_UPDATE_LOGIN,
              CREATED_BY,
              CREATION_DATE
            )
            select
              l_rec.BALANCE_TYPE_ID,
              l_rec.TRANS_LANG,
              l_rec.BASE_LANG,
              l_rec.BALANCE_NAME,
              l_rec.REPORTING_NAME,
              l_rec.LAST_UPDATE_DATE,
              l_rec.LAST_UPDATED_BY,
              l_rec.LAST_UPDATE_LOGIN,
              l_rec.CREATED_BY,
              l_rec.CREATION_DATE
            from dual
            where not exists (
                      select '1'
                        from pay_balance_types_tl btt
                       where btt.balance_type_id = l_rec.balance_type_id
                         and btt.language = l_rec.trans_lang);
Line: 6752

            select
              EC.CLASSIFICATION_ID,
              EC.CLASSIFICATION_NAME,
              EC.DESCRIPTION,
              L.LANGUAGE_CODE TRANS_LANG,
              B.LANGUAGE_CODE BASE_LANG,
              EC.LAST_UPDATE_DATE,
              EC.LAST_UPDATED_BY,
              EC.LAST_UPDATE_LOGIN,
              EC.CREATED_BY,
              EC.CREATION_DATE
            from PAY_ELEMENT_CLASSIFICATIONS EC,
              FND_LANGUAGES L,
              FND_LANGUAGES B
            where L.INSTALLED_FLAG in ('I', 'B')
              and B.INSTALLED_FLAG = 'B'
              and NVL(TO_CHAR(EC.BUSINESS_GROUP_ID),'Null Value')='Null Value'
              and
              ( not exists (
                      select '1'
                        from PAY_ELEMENT_CLASSIFICATIONS_TL ECT
                       where ECT.CLASSIFICATION_ID = EC.CLASSIFICATION_ID
                         and ECT.language = l.language_code)
               or exists (select '1' from PAY_ELEMENT_CLASSIFICATIONS_TL ect2
                          where ect2.CLASSIFICATION_ID = ec.CLASSIFICATION_ID
                          and   ect2.language = b.language_code
               and  nvl( ect2.description,'ec.description' ||'1') <> nvl(ec.description,ect2.description || '-1'))
              );
Line: 6788

            delete PAY_ELEMENT_CLASSIFICATIONS_TL
            where rowid in (select ectl.rowid
             from PAY_ELEMENT_CLASSIFICATIONS ec,
                  PAY_ELEMENT_CLASSIFICATIONS_TL ectl
             where ec.CLASSIFICATION_ID = ectl.CLASSIFICATION_ID
             and nvl(ec.DESCRIPTION, 'XXX') <>
                 nvl(ectl.DESCRIPTION, 'XXX')
             and NVL(TO_CHAR(ec.BUSINESS_GROUP_ID),'Null Value')='Null Value'
             and ectl.CLASSIFICATION_ID = l_rec.CLASSIFICATION_ID
             and ectl.language = l_rec.trans_lang);
Line: 6801

            insert into PAY_ELEMENT_CLASSIFICATIONS_TL
            (
            CLASSIFICATION_ID,
            CLASSIFICATION_NAME,
            DESCRIPTION,
            LANGUAGE,
            SOURCE_LANG,
            LAST_UPDATE_DATE,
            LAST_UPDATED_BY,
            LAST_UPDATE_LOGIN,
            CREATED_BY,
            CREATION_DATE
            )
            select
              l_rec.CLASSIFICATION_ID,
              l_rec.CLASSIFICATION_NAME,
              l_rec.DESCRIPTION,
              l_rec.TRANS_LANG,
              l_rec.base_lang,
              l_rec.LAST_UPDATE_DATE,
              l_rec.LAST_UPDATED_BY,
              l_rec.LAST_UPDATE_LOGIN,
              l_rec.CREATED_BY,
              l_rec.CREATION_DATE
            from dual
            where not exists (
                      select '1'
                        from PAY_ELEMENT_CLASSIFICATIONS_TL ECT
                       where ECT.CLASSIFICATION_ID = l_rec.CLASSIFICATION_ID
                         and ECT.language = l_rec.trans_lang);
Line: 6863

            select
              ET.ELEMENT_TYPE_ID,
              ET.ELEMENT_NAME,
              ET.REPORTING_NAME,
              ET.DESCRIPTION,
              L.LANGUAGE_CODE TRANS_LANG,
              B.LANGUAGE_CODE BASE_LANG,
              ET.LAST_UPDATE_DATE,
              ET.LAST_UPDATED_BY,
              ET.LAST_UPDATE_LOGIN,
              ET.CREATED_BY,
              ET.CREATION_DATE
            from PAY_ELEMENT_TYPES_F ET,
              FND_LANGUAGES L,
              FND_LANGUAGES B
            where L.INSTALLED_FLAG in ('I', 'B')
              and B.INSTALLED_FLAG = 'B'
              and NVL(TO_CHAR(ET.BUSINESS_GROUP_ID),'Null Value')='Null Value'
              and
              (       not exists (
                      select '1'
                        from PAY_ELEMENT_TYPES_F_TL ETT
                       where ETT.ELEMENT_TYPE_ID = ET.ELEMENT_TYPE_ID
                         and ETT.language = l.language_code)
               or exists (select '1' from PAY_ELEMENT_TYPES_F_TL ett2
                          where ett2.ELEMENT_TYPE_ID = et.ELEMENT_TYPE_ID
                          and   ett2.language = b.language_code
                          and   (nvl(ett2.reporting_name, 'XXX') <> nvl(et.reporting_name, 'XXX')
                                 or
                                 nvl(ett2.description, 'XXX') <> nvl(et.description, 'XXX')))
              );
Line: 6906

            delete PAY_ELEMENT_TYPES_F_TL
            where rowid in (select pettl.rowid
             from pay_element_types_f pet,
                  pay_element_types_f_tl pettl
             where pet.element_type_id = pettl.element_type_id
             and (
                  (nvl(pet.reporting_name, 'XXX') <>
                   nvl(pettl.reporting_name, 'XXX'))
                 or
                  (nvl(pet.description, 'XXX') <>
                   nvl(pettl.description, 'XXX'))
                 )
             and NVL(TO_CHAR(PET.BUSINESS_GROUP_ID),'Null Value')='Null Value'
             and pettl.ELEMENT_TYPE_ID = l_rec.ELEMENT_TYPE_ID
             and pettl.language = l_rec.trans_lang);
Line: 6925

            insert into PAY_ELEMENT_TYPES_F_TL
            (
            ELEMENT_TYPE_ID,
            ELEMENT_NAME,
            REPORTING_NAME,
            DESCRIPTION,
            LANGUAGE,
            SOURCE_LANG,
            LAST_UPDATE_DATE,
            LAST_UPDATED_BY,
            LAST_UPDATE_LOGIN,
            CREATED_BY,
            CREATION_DATE
            )
            select
              l_rec.ELEMENT_TYPE_ID,
              l_rec.ELEMENT_NAME,
              l_rec.REPORTING_NAME,
              l_rec.DESCRIPTION,
              l_rec.TRANS_LANG,
              l_rec.base_lang,
              l_rec.LAST_UPDATE_DATE,
              l_rec.LAST_UPDATED_BY,
              l_rec.LAST_UPDATE_LOGIN,
              l_rec.CREATED_BY,
              l_rec.CREATION_DATE
            from dual
            where not exists (
                      select '1'
                        from PAY_ELEMENT_TYPES_F_TL ETT
                       where ETT.ELEMENT_TYPE_ID = l_rec.ELEMENT_TYPE_ID
                         and ETT.language = l_rec.trans_lang);
Line: 6988

            select
              IV.INPUT_VALUE_ID,
              IV.NAME,
              L.LANGUAGE_CODE TRANS_LANG,
              B.LANGUAGE_CODE BASE_LANG,
              IV.LAST_UPDATE_DATE,
              IV.LAST_UPDATED_BY,
              IV.LAST_UPDATE_LOGIN,
              IV.CREATED_BY,
              IV.CREATION_DATE
            from PAY_INPUT_VALUES_F IV,
              FND_LANGUAGES L,
              FND_LANGUAGES B
            where  L.INSTALLED_FLAG in ('I', 'B')
              and B.INSTALLED_FLAG = 'B'
              and NVL(TO_CHAR(IV.BUSINESS_GROUP_ID),'Null Value')='Null Value'
              and not exists (
                      select '1'
                        from PAY_INPUT_VALUES_F_TL IVT
                       where IVT.INPUT_VALUE_ID = IV.INPUT_VALUE_ID
                         and IVT.language = l.language_code);
Line: 7022

              select flv.meaning
	      into l_translated_value
              from fnd_lookup_values       flv
              where flv.lookup_type = 'NAME_TRANSLATIONS'
              and     flv.lookup_code = 'PAY VALUE'
              and     flv.view_application_id = 3
              and     flv.security_group_id = 0
              and     flv.language = l_rec.trans_lang;
Line: 7035

            insert into PAY_INPUT_VALUES_F_TL
            (
            INPUT_VALUE_ID,
            NAME,
            LANGUAGE,
            SOURCE_LANG,
            LAST_UPDATE_DATE,
            LAST_UPDATED_BY,
            LAST_UPDATE_LOGIN,
            CREATED_BY,
            CREATION_DATE
            )
            select
              l_rec.INPUT_VALUE_ID,
              l_translated_value,
              l_rec.TRANS_LANG,
              l_rec.base_lang,
              l_rec.LAST_UPDATE_DATE,
              l_rec.LAST_UPDATED_BY,
              l_rec.LAST_UPDATE_LOGIN,
              l_rec.CREATED_BY,
              l_rec.CREATION_DATE
            from dual
            where not exists (
                      select '1'
                        from PAY_INPUT_VALUES_F_TL IVT
                       where IVT.INPUT_VALUE_ID = l_rec.INPUT_VALUE_ID
                         and IVT.language = l_rec.trans_lang);
Line: 7091

            select
              PT.PAYMENT_TYPE_ID,
              PT.PAYMENT_TYPE_NAME,
              PT.DESCRIPTION,
              L.LANGUAGE_CODE TRANS_LANG,
              B.LANGUAGE_CODE BASE_LANG,
              PT.LAST_UPDATE_DATE,
              PT.LAST_UPDATED_BY,
              PT.LAST_UPDATE_LOGIN,
              PT.CREATED_BY,
              PT.CREATION_DATE
            from PAY_PAYMENT_TYPES PT,
              FND_LANGUAGES L,
              FND_LANGUAGES B
            where L.INSTALLED_FLAG in ('I', 'B')
              and B.INSTALLED_FLAG = 'B'
              and not exists (
                      select '1'
                        from PAY_PAYMENT_TYPES_TL PTT
                       where PTT.PAYMENT_TYPE_ID = PT.PAYMENT_TYPE_ID
                         and PTT.language = l.language_code);
Line: 7122

            insert into PAY_PAYMENT_TYPES_TL
            (
            PAYMENT_TYPE_ID,
            PAYMENT_TYPE_NAME,
            DESCRIPTION,
            LANGUAGE,
            SOURCE_LANG,
            LAST_UPDATE_DATE,
            LAST_UPDATED_BY,
            LAST_UPDATE_LOGIN,
            CREATED_BY,
            CREATION_DATE
            )
            select
              l_rec.PAYMENT_TYPE_ID,
              l_rec.PAYMENT_TYPE_NAME,
              l_rec.DESCRIPTION,
              l_rec.TRANS_LANG,
              l_rec.base_lang,
              l_rec.LAST_UPDATE_DATE,
              l_rec.LAST_UPDATED_BY,
              l_rec.LAST_UPDATE_LOGIN,
              l_rec.CREATED_BY,
              l_rec.CREATION_DATE
            from dual
            where not exists (
                      select '1'
                        from PAY_PAYMENT_TYPES_TL PTT
                       where PTT.PAYMENT_TYPE_ID = l_rec.PAYMENT_TYPE_ID
                         and PTT.language = l_rec.trans_lang);
Line: 7184

            select
              M.INFORMATION_TYPE,
              L.LANGUAGE_CODE TRANS_LANG,
              B.LANGUAGE_CODE BASE_LANG,
              M.DESCRIPTION,
              M.LAST_UPDATE_DATE,
              M.LAST_UPDATED_BY,
              M.LAST_UPDATE_LOGIN,
              M.CREATED_BY,
              M.CREATION_DATE
            from PER_ASSIGNMENT_INFO_TYPES M,
              FND_LANGUAGES L,
              FND_LANGUAGES B
            where L.INSTALLED_FLAG in ('I', 'B')
              and B.INSTALLED_FLAG = 'B'
              and not exists ( select '1'
                                 from per_assignment_info_types_tl pait
                                where pait.information_type = m.information_type
                                  and pait.language         = l.language_code);
Line: 7213

            insert into PER_ASSIGNMENT_INFO_TYPES_TL
            (
            INFORMATION_TYPE,
            LANGUAGE,
            SOURCE_LANG,
            DESCRIPTION,
            LAST_UPDATE_DATE,
            LAST_UPDATED_BY,
            LAST_UPDATE_LOGIN,
            CREATED_BY,
            CREATION_DATE
            )
            select
              l_rec.INFORMATION_TYPE,
              l_rec.TRANS_LANG,
              l_rec.base_lang,
              l_rec.DESCRIPTION,
              l_rec.LAST_UPDATE_DATE,
              l_rec.LAST_UPDATED_BY,
              l_rec.LAST_UPDATE_LOGIN,
              l_rec.CREATED_BY,
              l_rec.CREATION_DATE
            from dual
            where not exists ( select '1'
                                 from per_assignment_info_types_tl pait
                                where pait.information_type =
                                                        l_rec.information_type
                                  and pait.language         = l_rec.trans_lang);
Line: 7273

            select
              M.ASSIGNMENT_STATUS_TYPE_ID,
              L.LANGUAGE_CODE TRANS_LANG,
              B.LANGUAGE_CODE BASE_LANG,
              M.USER_STATUS,
              M.LAST_UPDATE_DATE,
              M.LAST_UPDATED_BY,
              M.LAST_UPDATE_LOGIN,
              M.CREATED_BY,
              M.CREATION_DATE
            from PER_ASSIGNMENT_STATUS_TYPES M,
              FND_LANGUAGES L,
              FND_LANGUAGES B
            where L.INSTALLED_FLAG in ('I', 'B')
              and B.INSTALLED_FLAG = 'B'
              and NVL(TO_CHAR(M.BUSINESS_GROUP_ID),'Null Value')='Null Value'
              and not exists (
                      select '1'
                        from per_assignment_status_types_tl past
                       where past.assignment_status_type_id =
                                              m.assignment_status_type_id
                         and past.language = l.language_code);
Line: 7305

            insert into PER_ASSIGNMENT_STATUS_TYPES_TL
            (
            ASSIGNMENT_STATUS_TYPE_ID,
            LANGUAGE,
            SOURCE_LANG,
            USER_STATUS,
            LAST_UPDATE_DATE,
            LAST_UPDATED_BY,
            LAST_UPDATE_LOGIN,
            CREATED_BY,
            CREATION_DATE
            )
            select
              l_rec.ASSIGNMENT_STATUS_TYPE_ID,
              l_rec.TRANS_LANG,
              l_rec.base_lang,
              l_rec.USER_STATUS,
              l_rec.LAST_UPDATE_DATE,
              l_rec.LAST_UPDATED_BY,
              l_rec.LAST_UPDATE_LOGIN,
              l_rec.CREATED_BY,
              l_rec.CREATION_DATE
            from dual
            where not exists (
                      select '1'
                        from per_assignment_status_types_tl past
                       where past.assignment_status_type_id =
                                             l_rec.assignment_status_type_id
                         and past.language = l_rec.trans_lang);
Line: 7362

            select
              M.MONETARY_UNIT_ID,
              L.LANGUAGE_CODE TRANS_LANG,
              B.LANGUAGE_CODE BASE_LANG,
              M.MONETARY_UNIT_NAME,
              M.LAST_UPDATE_DATE,
              M.LAST_UPDATED_BY,
              M.LAST_UPDATE_LOGIN,
              M.CREATED_BY,
              M.CREATION_DATE
            from PAY_MONETARY_UNITS M,
                 FND_LANGUAGES L,
                 FND_LANGUAGES B
            where L.INSTALLED_FLAG in ('I', 'B')
              and B.INSTALLED_FLAG = 'B'
              and NVL(TO_CHAR(M.BUSINESS_GROUP_ID),'Null Value')='Null Value'
              and not exists (
                      select '1'
                        from PAY_MONETARY_UNITS_TL pmut
                       where pmut.monetary_unit_id =
                                              m.monetary_unit_id
                         and pmut.language = l.language_code);
Line: 7394

            insert into PAY_MONETARY_UNITS_TL
            (
            MONETARY_UNIT_ID,
            LANGUAGE,
            SOURCE_LANG,
            MONETARY_UNIT_NAME,
            LAST_UPDATE_DATE,
            LAST_UPDATED_BY,
            LAST_UPDATE_LOGIN,
            CREATED_BY,
            CREATION_DATE
            )
            select
              l_rec.MONETARY_UNIT_ID,
              l_rec.TRANS_LANG,
              l_rec.base_lang,
              l_rec.MONETARY_UNIT_NAME,
              l_rec.LAST_UPDATE_DATE,
              l_rec.LAST_UPDATED_BY,
              l_rec.LAST_UPDATE_LOGIN,
              l_rec.CREATED_BY,
              l_rec.CREATION_DATE
            from dual
            where not exists (
                      select '1'
                        from PAY_MONETARY_UNITS_TL pmut
                       where pmut.monetary_unit_id =
                                              l_rec.monetary_unit_id
                         and pmut.language = l_rec.trans_lang);
Line: 7450

            select
              bc.BALANCE_CATEGORY_ID,
              L.LANGUAGE_CODE TRANS_LANG,
              B.LANGUAGE_CODE BASE_LANG,
              bc.CATEGORY_NAME,
              bc.LAST_UPDATE_DATE,
              bc.LAST_UPDATED_BY,
              bc.LAST_UPDATE_LOGIN,
              bc.CREATED_BY,
              bc.CREATION_DATE
            from PAY_BALANCE_CATEGORIES_F bc,
                 FND_LANGUAGES L,
                 FND_LANGUAGES B
            where L.INSTALLED_FLAG in ('I', 'B')
              and B.INSTALLED_FLAG = 'B'
              and not exists (
                      select '1'
                        from PAY_BALANCE_CATEGORIES_F_TL bct
                       where bct.BALANCE_CATEGORY_ID = bc.BALANCE_CATEGORY_ID
                         and bct.language = l.language_code);
Line: 7480

            insert into PAY_BALANCE_CATEGORIES_F_TL
            (
            BALANCE_CATEGORY_ID,
            LANGUAGE,
            SOURCE_LANG,
            USER_CATEGORY_NAME,
            LAST_UPDATE_DATE,
            LAST_UPDATED_BY,
            LAST_UPDATE_LOGIN,
            CREATED_BY,
            CREATION_DATE
            )
            select
              l_rec.BALANCE_CATEGORY_ID,
              l_rec.TRANS_LANG,
              l_rec.base_lang,
              l_rec.CATEGORY_NAME,
              l_rec.LAST_UPDATE_DATE,
              l_rec.LAST_UPDATED_BY,
              l_rec.LAST_UPDATE_LOGIN,
              l_rec.CREATED_BY,
              l_rec.CREATION_DATE
            from dual
            where not exists (
                      select '1'
                        from PAY_BALANCE_CATEGORIES_F_TL bct
                       where bct.BALANCE_CATEGORY_ID = l_rec.BALANCE_CATEGORY_ID
                         and bct.language = l_rec.trans_lang);
Line: 7561

     select distinct legislation_code
     from hr_s_history;
Line: 7584

  select count(*)
  into g_debug_cnt
  from pay_patch_status
  where patch_name = 'HRGLOBAL_DEBUG';
Line: 7595

  select count(*)
  into   v_exception_counter
  from   hr_stu_exceptions;
Line: 7617

  select count(*)
  into   v_exception_counter
  from   hr_stu_exceptions;
Line: 7633

    select distinct legislation_code
    into   l_leg_code
    from   hr_s_history
    where  legislation_code = 'ZZ';