Description: Picks the manual class with the greatest summed payroll in the latest premium-history set, excluding clerical/sales/drivers, with two fallback passes
PROCEDUREget_6_digit_gov_class(in_policy_numINpolicy_period.policy_num%TYPE,in_pol_per_eff_dateINpolicy_period.policy_period_eff_date%TYPE,out_governing_classOUTprem_hist_class_coverage.manual_class_num%TYPE)ISmax_payrollNUMBER;/* Maximum payroll, to determine governing class */v_prem_hist_set_idprem_hist_summary.prem_hist_set_id%TYPE;/*********************************************************** This cursor gets the most recent set id if the function call has passed a null or 0 set id. ***********************************************************/CURSORset_id_curISSELECTMAX(prem_hist_set_id)FROMprem_hist_summaryWHEREpolicy_num=in_policy_numANDpolicy_period_eff_date=in_pol_per_eff_date;/*********************************************************** Create a cursor that gets the sum of payroll for each manual class on the particular set ***********************************************************/CURSORmax_payroll_curISSELECTmanual_class_num,SUM(NVL(manual_class_period_payroll,0))sum_payrollFROMprem_hist_class_coverageWHEREprem_hist_set_id=v_prem_hist_set_idANDSUBSTR(manual_class_num,1,4)NOTIN('8810','8742','7380')GROUPBYmanual_class_num;payroll_recmax_payroll_cur%ROWTYPE;CURSORmax_payroll_excluded_curISSELECTmanual_class_num,SUM(NVL(manual_class_period_payroll,0))sum_payrollFROMprem_hist_class_coverageWHEREprem_hist_set_id=v_prem_hist_set_idGROUPBYmanual_class_num;payroll_excluded_recmax_payroll_excluded_cur%ROWTYPE;CURSORget_lowest_class_curISSELECTMIN(manual_class_num)manual_class_numFROMprem_hist_class_coverageWHEREprem_hist_set_id=v_prem_hist_set_id;get_lowest_class_recget_lowest_class_cur%ROWTYPE;/** local procedure(s) **//** This procedure closes all the open cursors **/
Note: Statements marked with * were inferred from code structure, naming conventions, or
contextual evidence where direct confirmation was not available in source artifacts. Statements
marked with ** could not be confirmed; treat as unknown until verified.