7: g_binds g_bind_rec_tab_type;
8: g_binds_reset g_bind_rec_tab_type;
9:
10: -- Templates for SELECT columns
11: g_template_standard VARCHAR2(1000);
12: g_template_bucket VARCHAR2(1000);
13: g_template_sepcat VARCHAR2(1000);
14: g_template_sepcat_bucket VARCHAR2(1000);
15:
26: /* SELECT */
27: /* ------ */
28: /* For details of the SELECT column list see package header */
29: /* */
30: /* All columns have one of a few standard formats. Global variables store */
31: /* templates for these formats with tags in for swapping in and out parts */
32: /* of the template (such as measure column, bucket column, bucket value) */
33: /* */
34: /* The columns in the select clause are controlled by various fields in the */
98:
99: IF p_use_snapshot THEN
100:
101: /* Define generic select column */
102: g_template_standard :=
103: 'SUM(CASE WHEN wcnt.effective_date =
104: THEN
105: ELSE 0
106: END)';
132:
133: ELSE
134:
135: /* Define generic select column */
136: g_template_standard :=
137: 'SUM(CASE WHEN wcnt.effective_date BETWEEN
138: THEN
139: ELSE 0
140: END)';
484: /******************************************************************************/
485: FUNCTION build_columns
486: (p_parameter_rec IN hri_oltp_pmv_util_param.HRI_PMV_PARAM_REC_TYPE,
487: p_wcnt_chg_params IN wcnt_chg_fact_param_type,
488: p_template_standard IN VARCHAR2,
489: p_template_bucket IN VARCHAR2,
490: p_measure_alias IN VARCHAR2)
491: RETURN VARCHAR2 IS
492:
503:
504: /* Always get the column for the current period */
505: /************************************************/
506: l_column_list := l_column_list || format_column
507: (p_column_string => p_template_standard
508: ,p_start_date => g_binds('TIME_CURR_START_DATE')
509: ,p_end_date => g_binds('TIME_CURR_END_DATE')
510: ,p_bucket_id => NULL
511: ,p_column_alias => 'curr_' || p_measure_alias);
513: /* Check for comparison period columns */
514: /***************************************/
515: IF (p_wcnt_chg_params.include_comp = 'Y') THEN
516: l_column_list := l_column_list || format_column
517: (p_column_string => p_template_standard
518: ,p_start_date => g_binds('TIME_COMP_START_DATE')
519: ,p_end_date => g_binds('TIME_COMP_END_DATE')
520: ,p_bucket_id => NULL
521: ,p_column_alias => 'comp_' || p_measure_alias);
659: p_fact_table = 'hri_mds_sup_wcnt_chg_mv') THEN
660: l_mgr_direct_condition := 'AND 1 - suph.sub_relative_level = wcnt.direct_record_ind'
661: || g_rtn;
662: l_gen_direct_condition := 'AND wcnt.direct_record_ind = 0' || g_rtn;
663: l_template_sepcat := g_template_standard;
664: l_template_sepcat_bucket := g_template_bucket;
665: ELSE
666: l_mgr_direct_condition := 'AND (suph.sub_relative_level = 1 ' || g_rtn ||
667: ' OR wcnt.direct_ind = 1)' || g_rtn;
664: l_template_sepcat_bucket := g_template_bucket;
665: ELSE
666: l_mgr_direct_condition := 'AND (suph.sub_relative_level = 1 ' || g_rtn ||
667: ' OR wcnt.direct_ind = 1)' || g_rtn;
668: l_template_sepcat := g_template_standard;
669: l_template_sepcat_bucket := g_template_bucket;
670: END IF;
671:
672: /* Set dynamic SQL based on view by (manager special case for non-KPI reports) */
713: IF (p_wcnt_chg_params.include_hire = 'Y') THEN
714: l_col_list := l_col_list || build_columns
715: (p_parameter_rec => p_parameter_rec,
716: p_wcnt_chg_params => p_wcnt_chg_params,
717: p_template_standard => REPLACE(g_template_standard, '
719: p_measure_alias => 'hire_hdc');
720: END IF;
721:
723: IF (p_wcnt_chg_params.include_trin = 'Y') THEN
724: l_col_list := l_col_list || build_columns
725: (p_parameter_rec => p_parameter_rec,
726: p_wcnt_chg_params => p_wcnt_chg_params,
727: p_template_standard => REPLACE(g_template_standard, '
729: p_measure_alias => 'transfer_in_hdc');
730: END IF;
731:
733: IF (p_wcnt_chg_params.include_trout = 'Y') THEN
734: l_col_list := l_col_list || build_columns
735: (p_parameter_rec => p_parameter_rec,
736: p_wcnt_chg_params => p_wcnt_chg_params,
737: p_template_standard => REPLACE(g_template_standard, '
739: p_measure_alias => 'transfer_out_hdc');
740: END IF;
741:
743: IF (p_wcnt_chg_params.include_term = 'Y') THEN
744: l_col_list := l_col_list || build_columns
745: (p_parameter_rec => p_parameter_rec,
746: p_wcnt_chg_params => p_wcnt_chg_params,
747: p_template_standard => REPLACE(g_template_standard, '
749: p_measure_alias => 'termination_hdc');
750: END IF;
751:
752: IF (p_wcnt_chg_params.include_sep = 'Y') THEN
753: l_col_list := l_col_list || build_columns
754: (p_parameter_rec => p_parameter_rec,
755: p_wcnt_chg_params => p_wcnt_chg_params,
756: p_template_standard => REPLACE(g_template_standard, '
758: p_measure_alias => 'separation_hdc');
759: END IF;
760:
761: IF (p_wcnt_chg_params.include_sep_vol = 'Y') THEN
762: l_col_list := l_col_list || build_columns
763: (p_parameter_rec => p_parameter_rec,
764: p_wcnt_chg_params => p_wcnt_chg_params,
765: p_template_standard => REPLACE(REPLACE(l_template_sepcat,
766: '
767: '
768: p_template_bucket => REPLACE(REPLACE(l_template_sepcat_bucket,
769: '
774: IF (p_wcnt_chg_params.include_sep_inv = 'Y') THEN
775: l_col_list := l_col_list || build_columns
776: (p_parameter_rec => p_parameter_rec,
777: p_wcnt_chg_params => p_wcnt_chg_params,
778: p_template_standard => REPLACE(REPLACE(l_template_sepcat,
779: '
780: '
781: p_template_bucket => REPLACE(REPLACE(l_template_sepcat_bucket,
782: '
788: IF (p_wcnt_chg_params.include_low = 'Y') THEN
789: l_col_list := l_col_list || build_columns
790: (p_parameter_rec => p_parameter_rec,
791: p_wcnt_chg_params => p_wcnt_chg_params,
792: p_template_standard => REPLACE(g_template_standard, '
794: p_measure_alias => 'low_months');
795:
796: l_col_list := l_col_list || build_columns
795:
796: l_col_list := l_col_list || build_columns
797: (p_parameter_rec => p_parameter_rec,
798: p_wcnt_chg_params => p_wcnt_chg_params,
799: p_template_standard => REPLACE(g_template_standard, '
801: p_template_bucket => REPLACE(g_template_bucket, '
802: 'effective_date - pow_start_date'),
803: p_measure_alias => 'low_days');