 --please change the misdate and runskey values at line number 35 and 36 accordingly 
 INSERT INTO fct_reg_run_legal_entity_map (
        f_intracomp_elimination_ind,
        n_date_skey,
        n_entity_party_skey,
        n_entity_type_skey,
        n_lv_hierarchy_skey,
        n_reporting_entity_skey,
        n_rle_ownership_type_skey,
        n_rle_primary_function_skey,
        n_run_consolidation_type_skey,
        n_run_skey,
        v_iso_reporting_currency_cd
    )
        SELECT
            CASE
                WHEN run_exe_parameters_intra.v_param_value_code = 'YES' THEN
                    'Y'
                ELSE
                    'N'
            END,
            dim_dates.n_date_skey,
            coalesce(dim_party.n_party_skey, nvl2(dim_org_structure.v_party_id, - 1, 0)),
            coalesce(dim_entity_type.n_entity_type_skey, nvl2(dim_org_structure.v_entity_type, - 1, 0)),
            coalesce(dim_lv_hierarchies.n_lv_hierarchy_skey, nvl2(run_exe_parameters_lv_hier.v_param_value_code, - 1, 0)),
            dim_org_structure.n_entity_skey,
            coalesce(a_dim_le_ownership_type.n_ownership_type_skey, nvl2(dim_org_structure.v_lv_ownership_type, - 1, 0)),
            coalesce(dim_instn_primary_function.n_instn_primary_function_skey, nvl2(dim_org_structure.v_primary_function_code, - 1, 0)),
            coalesce(dim_run_consolidation_type.n_run_consolidation_type_skey, nvl2(run_exe_parameters_consl.v_param_value_code, - 1,
            0)),
            dim_run.n_run_skey,
            run_exe_parameters_rcy.v_param_value_code
        FROM
                 dim_org_structure
            INNER JOIN dim_dates ON dim_dates.d_calendar_date = TO_DATE('20151231', 'YYYYMMDD')
            INNER JOIN dim_run ON dim_run.n_run_skey = 5
                                  AND dim_dates.d_calendar_date >= dim_org_structure.d_record_start_date
                                  AND dim_dates.d_calendar_date <= dim_org_structure.d_record_end_date
            INNER JOIN run_exe_parameters run_exe_parameters_rcy ON dim_run.n_run_skey = run_exe_parameters_rcy.n_run_skey
                                                                    AND run_exe_parameters_rcy.v_param_id = 'RCY'
            INNER JOIN run_exe_parameters run_exe_parameters_le ON dim_run.n_run_skey = run_exe_parameters_le.n_run_skey
                                                                   AND run_exe_parameters_le.v_param_id = 'LE'
                                                                   AND run_exe_parameters_le.v_param_value_code = dim_org_structure.v_entity_code
            INNER JOIN run_exe_parameters run_exe_parameters_consl ON dim_run.n_run_skey = run_exe_parameters_consl.n_run_skey
                                                                      AND run_exe_parameters_consl.v_param_id = 'CONSOTYPE'
                                                                      AND run_exe_parameters_consl.v_param_value_code = 'CONSL'
            INNER JOIN run_exe_parameters run_exe_parameters_lv_hier ON dim_run.n_run_skey = run_exe_parameters_lv_hier.n_run_skey
                                                                        AND run_exe_parameters_lv_hier.v_param_id = 'CONSOHIER'
            LEFT OUTER JOIN dim_entity_type ON dim_org_structure.v_entity_type = dim_entity_type.v_entity_type_code
                                               AND dim_dates.d_calendar_date >= dim_entity_type.d_record_start_date
                                               AND dim_dates.d_calendar_date <= dim_entity_type.d_record_end_date
            LEFT OUTER JOIN dim_party ON dim_org_structure.v_party_id = dim_party.v_party_id
                                         AND dim_dates.d_calendar_date >= dim_party.d_record_start_date
                                         AND dim_dates.d_calendar_date <= dim_party.d_record_end_date
            LEFT OUTER JOIN run_exe_parameters run_exe_parameters_intra ON dim_run.n_run_skey = run_exe_parameters_intra.n_run_skey
                                                                           AND run_exe_parameters_intra.v_param_id = 'INTRAFLAG'
            LEFT OUTER JOIN dim_ownership_type a_dim_le_ownership_type ON dim_org_structure.v_lv_ownership_type = a_dim_le_ownership_type.
            v_ownership_type
                                                                          AND dim_dates.d_calendar_date >= a_dim_le_ownership_type.d_record_start_date
                                                                          AND dim_dates.d_calendar_date <= a_dim_le_ownership_type.d_record_end_date
            LEFT OUTER JOIN dim_instn_primary_function ON dim_org_structure.v_primary_function_code = dim_instn_primary_function.v_instn_primary_function_code
                                                          AND dim_dates.d_calendar_date >= dim_instn_primary_function.d_record_start_date
                                                          AND dim_dates.d_calendar_date <= dim_instn_primary_function.d_record_end_date
            LEFT OUTER JOIN dim_lv_hierarchies ON run_exe_parameters_lv_hier.v_param_value_code = dim_lv_hierarchies.v_lv_hierarchy_name
                                                  AND dim_dates.d_calendar_date >= dim_lv_hierarchies.d_record_start_date
                                                  AND dim_dates.d_calendar_date <= dim_lv_hierarchies.d_record_end_date
            LEFT OUTER JOIN dim_run_consolidation_type ON run_exe_parameters_consl.v_param_value_code = dim_run_consolidation_type.v_run_consolidation_type
                                                          AND dim_dates.d_calendar_date >= dim_run_consolidation_type.d_record_start_date
                                                          AND dim_dates.d_calendar_date <= dim_run_consolidation_type.d_record_end_date;
														  
commit;