[Home] [Help]
PACKAGE BODY: APPS.PER_CA_EE_EXTRACT_PKG
Source
1 PACKAGE BODY per_ca_ee_extract_pkg AS
2 /* $Header: pecaeerp.pkb 120.1.12020000.2 2012/07/05 01:35:14 amnaraya ship $ */
3
4 v_naic naic_tab;
5 v_naic_count naic_count_tab;
6 v_sorted_naic naic_tab;
7 v_sorted_naic_count naic_count_tab;
8
9 v_person_type_temp person_type_tab;
10 v_person_type person_type_tab;
11 v_job_id_temp job_id_tab;
12 v_job_id job_id_tab;
13 v_job_temp job_tab;
14 v_job job_tab;
15
16
17 FUNCTION job_exists (p_job_id IN NUMBER)
18 RETURN VARCHAR2 IS
19 BEGIN
20 IF v_job_id.COUNT > 0 THEN
21 IF v_job_id.EXISTS(p_job_id) THEN
22 RETURN v_job(p_job_id);
23 END IF;
24 END IF;
25
26 RETURN NULL;
27
28 END job_exists;
29
30 FUNCTION person_type_exists (p_person_type IN NUMBER)
31 RETURN VARCHAR2 IS
32 BEGIN
33 IF v_person_type.COUNT > 0 THEN
34 IF v_person_type.EXISTS(p_person_type) THEN
35 RETURN 'Y';
36 END IF;
37 END IF;
38
39 RETURN NULL;
40
41 END person_type_exists;
42
43 FUNCTION employee_promotions (p_assignment_id IN NUMBER,
44 p_person_id IN NUMBER,
45 p_business_group_id IN NUMBER,
46 p_start_date IN DATE,
50 v_promotions_count NUMBER := 0;
47 p_end_date IN DATE,
48 p_boolean IN VARCHAR2)
49 RETURN NUMBER IS
51 BEGIN
52 SELECT count(*)
53 INTO v_promotions_count
54 FROM per_pay_proposals_v2
55 WHERE assignment_id = p_assignment_id
56 AND approved = 'Y'
57 AND change_date BETWEEN p_start_date
58 AND p_end_date
59 AND proposal_reason = 'PROM';
60
61 v_promotions_count :=
62 v_promotions_count +
63 per_fastformula_events_utility.per_fastformula_event('PROMOTION',
64 'Promotion',
65 p_business_group_id,
66 p_person_id,
67 p_start_date,
68 p_end_date);
69 IF p_boolean = 'Y' THEN
70
71 IF v_promotions_count > 0 THEN
72 RETURN 1;
73 ELSE
74 RETURN 0;
75 END IF;
76
77 ELSE
78
79 RETURN v_promotions_count;
80
81 END IF;
82
83 END employee_promotions;
84
85 FUNCTION find_naic (p_naic_code IN VARCHAR2)
86 RETURN NUMBER IS
87 BEGIN
88 IF p_naic_code IS NOT NULL THEN
89
90 IF v_naic.COUNT > 0 THEN
91
92 FOR i IN v_naic.first..v_naic.last LOOP
93 IF p_naic_code = v_naic(i) THEN
94 RETURN i;
95 END IF;
96 END LOOP;
97
98 END IF;
99
100 END IF;
101
102 RETURN 0;
103
104 END find_naic;
105
106 PROCEDURE sort_naic IS
107 v_max number;
108 v_max_index number;
109 BEGIN
110 IF v_naic.COUNT > 0 THEN
111
112 FOR i IN v_naic.first..v_naic.last LOOP
113
114 v_max := 0;
115 v_max_index := 0;
116
117 IF v_naic_count.COUNT > 0 THEN
118
119 FOR j IN v_naic_count.first..v_naic_count.last LOOP
120
121 IF v_max < v_naic_count(j) THEN
122 v_max := v_naic_count(j);
123 v_max_index := j;
124 END IF;
125
126 END LOOP;
127
128 END IF;
129
130 IF v_max_index > 0 THEN
131
132 v_sorted_naic(i) := v_naic(v_max_index);
133 v_sorted_naic_count(i) := v_naic_count(v_max_index);
134 v_naic_count(v_max_index) := -1;
135
136 END IF;
137
138 END LOOP;
139 END IF;
140
141 END sort_naic;
142
143 PROCEDURE calc_naic_totals (p_naic_code IN VARCHAR2,
144 p_date_all_emp IN DATE,
145 p_business_group_id IN NUMBER,
146 p_year IN VARCHAR2) IS
147
148 v_person_id person_tab;
149 v_softcoding_keyflex softcoding_tab;
150 v_org_information8 org_info8_tab;
151 v_organization_id organization_id_tab;
152 v_segment1 segment1_tab;
153 v_segment6 segment6_tab;
154 v_commit_limit NATURAL := 200;
155 v_old_row_count NUMBER := 0;
156 v_new_row_count NUMBER := 0;
157 v_rows_in_collect NUMBER := 0;
158 v_index NUMBER := 0;
159 v_init NUMBER := 0;
160 v_count NUMBER := 0;
161 v_year_end DATE := ADD_MONTHS(TRUNC(TO_DATE(p_year,'YYYY'),'Y'), 12) -1;
162
163 CURSOR cur_person IS
164 SELECT DISTINCT paf.person_id,
165 paf.soft_coding_keyflex_id,
166 hsck.segment1,
167 hsck.segment6
168 FROM per_assignments_f paf,
169 per_people_f ppf,
170 per_person_types ppt,
171 per_jobs pj,
172 hr_soft_coding_keyflex hsck
173 WHERE
174 p_date_all_emp BETWEEN
175 paf.effective_start_date AND
176 paf.effective_end_date
177 AND paf.business_group_id = p_business_group_id
178 AND paf.primary_flag = 'Y'
179 AND paf.job_id + 0 = pj.job_id
180 AND pj.job_information_category = 'CA'
181 AND paf.person_id =ppf.person_id
182 AND p_date_all_emp BETWEEN
183 ppf.effective_start_date AND
184 ppf.effective_end_date
185 AND ppf.person_type_id =ppt.person_type_id
186 AND ppt.system_person_type='EMP'
187 AND paf.soft_coding_keyflex_id = hsck.soft_coding_keyflex_id
188 AND EXISTS
189 (SELECT 'X'
190 FROM per_pay_proposals_v2 pppv
191 WHERE pppv.business_group_id = p_business_group_id
192 AND pppv.assignment_id = paf.assignment_id
193 AND pppv.approved = 'Y'
194 AND pppv.change_date <= v_year_end)
195 AND EXISTS
196 (SELECT 1
197 FROM hr_lookups hl
198 WHERE pj.job_information1 = hl.lookup_code
199 AND hl.lookup_type = 'EEOG' );
200
201 CURSOR cur_gre_naic IS
205 hr_organization_units hou
202 SELECT hoi.organization_id,
203 hoi.org_information8
204 FROM hr_organization_information hoi,
206 WHERE hou.business_group_id = p_business_group_id
207 AND hou.organization_id = hoi.organization_id
208 AND hoi.org_information_context = 'Canada Employer Identification'
209 AND hoi.org_information8 IS NOT NULL;
210
211 BEGIN
212
213 OPEN cur_gre_naic;
214 FETCH cur_gre_naic BULK COLLECT INTO
215 v_organization_id,
216 v_org_information8;
217
218 CLOSE cur_gre_naic;
219
220 OPEN cur_person;
221 LOOP
222 FETCH cur_person BULK COLLECT INTO
223 v_person_id,
224 v_softcoding_keyflex,
225 v_segment1,
226 v_segment6
227 LIMIT v_commit_limit;
228
229 v_old_row_count := v_new_row_count;
230 v_new_row_count := cur_person%ROWCOUNT;
231
232 v_rows_in_collect := v_new_row_count - v_old_row_count;
233
234 EXIT WHEN (v_rows_in_collect = 0);
235
236 IF v_person_id.COUNT > 0 THEN
237
238 FOR i IN v_person_id.first..v_person_id.last LOOP
239
240 IF p_naic_code IS NOT NULL THEN
241
242 IF (v_segment6(i) = p_naic_code) THEN
243
244 IF v_init = 0 THEN
245 v_naic(1) := p_naic_code;
246 v_naic_count(1) := 1;
247 v_init := 1;
248 ELSE
249 v_naic_count(1) := v_naic_count(1) + 1;
250 END IF;
251
252 ELSIF (v_segment6(i) IS NULL) THEN
253
254 IF v_organization_id.COUNT > 0 THEN
255
256 FOR k IN v_organization_id.first..v_organization_id.last LOOP
257
258 IF (v_segment1(i) = to_char (v_organization_id(k)) AND
259 v_org_information8(k) = p_naic_code) THEN
260
261 IF v_init = 0 THEN
262 v_naic(1) := p_naic_code;
263 v_naic_count(1) := 1;
264 v_init := 1;
265 ELSE
266 v_naic_count(1) := v_naic_count(1) + 1;
267 END IF;
268
269 EXIT;
270
271 END IF;
272
273 END LOOP;
274
275 END IF;
276
277 END IF;
278 ELSE
279 IF (v_segment6(i) IS NOT NULL) THEN
280
281 v_index := find_naic(v_segment6(i));
282
283 IF v_index = 0 THEN
284 v_count := v_naic.COUNT;
285 v_naic(v_count + 1) := v_segment6(i);
286 v_naic_count(v_count + 1) := 1;
287 ELSE
288 v_naic_count(v_index) := v_naic_count(v_index) + 1;
289 END IF;
290
291 v_index := 0;
292
293 ELSE
294 IF v_organization_id.COUNT > 0 THEN
295
296 FOR k IN v_organization_id.first..v_organization_id.last LOOP
297
298 IF (v_segment1(i) = to_char(v_organization_id(k))) THEN
299
300 v_index := find_naic(v_org_information8(k));
301
302 IF v_index = 0 THEN
303 v_count := v_naic.COUNT;
304 v_naic(v_count + 1) := v_org_information8(k);
305 v_naic_count(v_count + 1) := 1;
306 ELSE
307 v_naic_count(v_index) := v_naic_count(v_index) + 1;
308 END IF;
309
310 v_index := 0;
311 EXIT;
312
313 END IF;
314
315 END LOOP;
316
317 END IF;
318
319 END IF;
320
321 END IF;
322
323 END LOOP;
324
325 END IF;
326
327 COMMIT;
328
329 END LOOP;
330 CLOSE cur_person;
331
332 sort_naic;
333
334 END calc_naic_totals;
335
336 --
337 function check_gre_without_naic(p_business_group_id NUMBER,
338 p_gre_name OUT NOCOPY tab_varchar2)
339 return number is
340 begin
341
342 declare
343
344 cursor cur_gre_without_naic is
345 select
346 hou.name gre_name
347 from
348 hr_organization_information hoi,
349 hr_organization_units hou
350 where
351 hou.business_group_id = p_business_group_id and
352 hou.organization_id = hoi.organization_id and
356 j number := 1;
353 hoi.org_information_context = 'Canada Employer Identification' and
354 hoi.org_information8 is null;
355
357
358 begin
359
360 hr_utility.trace('Function check_gre_without_naic starte Here !!!!!');
361
362 for i in cur_gre_without_naic loop
363
364 p_gre_name(j) := i.gre_name;
365 j := j + 1;
366
367 end loop;
368
369 if j <> 1 then
370 return -1;
371 else
372 return 1;
373 end if;
374
375 end;
376
377 exception
378 when others then
379 p_gre_name.delete;
380 raise;
381
382 end; -- End of function check_gre_without_naic
383 --
384 -----------------------------------------------------------------------------
385 -- Name form1 --
386 -- Purpose --
387 -- This procedure is used to populate per_ca_ee_report_lines for the --
388 -- form1 in the Employment Equity Report. --
389 -- --
390 -- --
391 -----------------------------------------------------------------------------
392 --
393 function form1(p_business_group_id in number,
394 p_request_id in number,
395 p_year in varchar2,
396 p_naic_code in varchar2,
397 p_date_all_emp in date,
398 p_date_tmp_emp in date) return number is
399
400 l_year_start date;
401 l_year_end date;
402
403 begin
404
405 l_year_start := trunc(to_date(p_year,'YYYY'),'Y');
406 l_year_end := add_months(trunc(to_date(p_year,'YYYY'),'Y'), 12) -1;
407
408 declare
409
410 cursor cur_org_info is
411 select
412 houv.name,houv.address_line_1,
413 houv.address_line_2,houv.address_line_3,
414 houv.town_or_city, houv.region_1,
415 houv.postal_code,houv.country, houv.organization_id ,
416 hoi.org_information1
417 from
418 hr_organization_units_v houv,
419 hr_organization_information hoi
420 where
421 houv.organization_id=hoi.organization_id and
422 upper(ltrim(rtrim(hoi.org_information_context)))
423 = 'BUSINESS GROUP INFORMATION'
424 and houv.business_group_id = p_business_group_id;
425
426 v_name hr_organization_units_v.name%TYPE;
427 v_address_line_1 hr_organization_units_v.address_line_1%TYPE;
428 v_address_line_2 hr_organization_units_v.address_line_2%TYPE;
429 v_address_line_3 hr_organization_units_v.address_line_3%TYPE;
430 v_town_or_city hr_organization_units_v.town_or_city%TYPE;
431 v_region_1 hr_organization_units_v.region_1%TYPE;
432 v_postal_code hr_organization_units_v.postal_code%TYPE;
433 v_country hr_organization_units_v.country%TYPE;
434 v_organization_id hr_organization_units_v.organization_id%TYPE;
435 v_short_name hr_organization_information.org_information1%TYPE;
436
437
438 cursor cur_employee_info is
439 select
440 org_information1 ceo_name,
441 org_information3 ceo_position,
442 org_information2 contact_name,
443 org_information4 contact_position,
444 org_information5 contact_phone
445 from
446 hr_organization_information
447 where
448 upper(ltrim(rtrim(org_information_context)))
449 = 'EMPLOYMENT EQUITY INFORMATION' and
450 organization_id = v_organization_id;
451
452 cursor cur_employment_category is
453 select
454 employment_category employment_category,
455 count(distinct l_person_id) count_category
456 from (
457 select
458 distinct(paf.person_id) l_person_id,
459 substr(paf.employment_category,1,2) employment_category
460 from
461 per_people_f ppf,
462 per_assignments_f paf,
463 per_person_types ppt,
464 hr_soft_coding_keyflex hsck,
465 per_jobs pj,
466 hr_lookups hl
467 where
468 ppf.person_type_id = ppt.person_type_id and
469 upper(ltrim(rtrim(ppt.system_person_type)))='EMP' and
470 decode(paf.employment_category,'PT',p_date_tmp_emp,l_year_end) between
471 ppf.effective_start_date and
472 ppf.effective_end_date and
473 ppf.person_id = paf.person_id and
474 decode(paf.employment_category,'PT',p_date_tmp_emp,l_year_end) between
475 paf.effective_start_date and
476 paf.effective_end_date and
477 paf.business_group_id = p_business_group_id and
478 paf.primary_flag = 'Y' and
479 paf.employment_category is not null and
480 substr(paf.employment_category,1,2) in ('FR','PR','PT') and
481 paf.job_id = pj.job_id and
482 pj.job_information_category = 'CA' and
483 pj.job_information1 = hl.lookup_code and
484 hl.lookup_type = 'EEOG' and
485 (
486 (p_naic_code is not null and
487 (
488 (
489 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
490 hsck.segment6 is not null and
491 hsck.segment6 = p_naic_code
492 )
493 OR
494 (
495 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
496 hsck.segment6 is null and
497 hsck.segment1 in (select segment3
498 from per_ca_ee_report_lines
502 segment2 = p_naic_code)
499 where request_id = p_request_id and
500 context = 'FORM13' and
501 segment1 = 'NAIC' and
503 )
504 )
505
506 ) -- End of p_naic_code is not null
507 OR
508 (p_naic_code is null and
509 (
510 (
511 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
512 hsck.segment6 is not null and
513 hsck.segment6 in (select segment3
514 from per_ca_ee_report_lines
515 where request_id = p_request_id and
516 context = 'FORM13' and
517 segment1 = 'NAIC')
518 )
519 OR
520 (
521 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
522 hsck.segment6 is null and
523 hsck.segment1 in (select segment3
524 from per_ca_ee_report_lines
525 where request_id = p_request_id and
526 context = 'FORM13' and
527 segment1 = 'NAIC')
528 )
529 )
530 ) -- End of p_naic_code is null
531 ) and
532 exists
533 (
534 select 'X'
535 from per_pay_proposals_v2 pppv
536 where pppv.business_group_id = p_business_group_id and
537 pppv.assignment_id = paf.assignment_id and
538 pppv.approved = 'Y' and
539 pppv.change_date <=
540 decode(substr(paf.employment_category,1,2),
541 'PT',p_date_tmp_emp,l_year_end)
542 ) -- End of exists
543 union all
544 select
545 distinct(paf.person_id) l_person_id,
546 'FR' employment_category
547 from
548 per_people_f ppf,
549 per_assignments_f paf,
550 per_person_types ppt,
551 hr_soft_coding_keyflex hsck,
552 per_jobs pj,
553 hr_lookups hl
554 where
555 ppf.person_type_id = ppt.person_type_id and
556 upper(ltrim(rtrim(ppt.system_person_type)))='EMP' and
557 l_year_end between
558 ppf.effective_start_date and
559 ppf.effective_end_date and
560 ppf.person_id = paf.person_id and
561 l_year_end between
562 paf.effective_start_date and
563 paf.effective_end_date and
564 paf.business_group_id = p_business_group_id and
565 paf.primary_flag = 'Y' and
566 paf.job_id = pj.job_id and
567 pj.job_information_category = 'CA' and
568 pj.job_information1 = hl.lookup_code and
569 hl.lookup_type = 'EEOG' and
570 (paf.employment_category is null OR
571 substr(paf.employment_category,1,2) not in ('FR','PR','PT')
572 ) and
573 (
574 (p_naic_code is not null and
575 (
576 (
577 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
578 hsck.segment6 is not null and
579 hsck.segment6 = p_naic_code
580 )
581 OR
582 (
583 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
584 hsck.segment6 is null and
585 hsck.segment1 in (select segment3
586 from per_ca_ee_report_lines
587 where request_id = p_request_id and
588 context = 'FORM13' and
589 segment1 = 'NAIC' and
590 segment2 = p_naic_code)
591 )
592 )
593
594 ) -- End of p_naic_code is not null
595 OR
596 (p_naic_code is null and
597 (
598 (
599 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
600 hsck.segment6 is not null and
601 hsck.segment6 in (select segment3
602 from per_ca_ee_report_lines
603 where request_id = p_request_id and
604 context = 'FORM13' and
605 segment1 = 'NAIC')
606 )
607 OR
608 (
609 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
610 hsck.segment6 is null and
611 hsck.segment1 in (select segment3
612 from per_ca_ee_report_lines
613 where request_id = p_request_id and
614 context = 'FORM13' and
615 segment1 = 'NAIC')
616 )
617 )
618 ) -- End od p_naic_code is null
619 ) and
620 exists
621 (
622 select 'X'
623 from per_pay_proposals_v2 pppv
624 where pppv.business_group_id = p_business_group_id and
625 pppv.assignment_id = paf.assignment_id and
626 pppv.approved = 'Y' and
627 pppv.change_date <=
628 decode(substr(paf.employment_category,1,2),
629 'PT',p_date_tmp_emp,l_year_end)
630 ) -- End of exists
631 ) -- End of from
632 group by employment_category
633 order by employment_category;
634
638 hl1.meaning meaning
635 cursor cur_province_cma(pc number) is
636 select
637 count(distinct paf.person_id) count_province_cma,
639 from
640 per_assignments_f paf,
641 hr_locations hl,
642 hr_lookups hl1,
643 per_people_f ppf ,
644 per_person_types ppt,
645 per_jobs pj,
646 hr_lookups hl2
647 where
648 upper(ltrim(rtrim(hl1.lookup_type)))=decode(pc,1,'CA_PROVINCE',
649 2,'CA_CMA')and
650 upper(ltrim(rtrim(hl1.lookup_code)))
651 = decode(pc,1,upper(ltrim(rtrim(hl.region_1))),
652 2,upper(ltrim(rtrim(hl.region_2)))) and
653 hl.location_id=paf.location_id and
654 p_date_all_emp between
655 paf.effective_start_date and
656 paf.effective_end_date and
657 paf.business_group_id=p_business_group_id and
658 paf.primary_flag = 'Y' and
659 paf.job_id = pj.job_id and
660 pj.job_information_category = 'CA' and
661 pj.job_information1 = hl2.lookup_code and
662 hl2.lookup_type = 'EEOG' and
663 paf.person_id=ppf.person_id and
664 p_date_all_emp between
665 ppf.effective_start_date and
666 ppf.effective_end_date and
667 ppf.person_type_id=ppt.person_type_id and
668 ppt.system_person_type='EMP' and
669 exists
670 (
671 select 'X'
672 from per_pay_proposals_v2 pppv
673 where pppv.business_group_id = p_business_group_id and
674 pppv.assignment_id = paf.assignment_id and
675 pppv.approved = 'Y' and
676 pppv.change_date <= l_year_end
677 ) -- End of exists
678 group by hl1.meaning;
679
680 cursor cur_cma_notfound is
681 select
682 ltrim(rtrim(hl.meaning)) meaning
683 from
684 hr_lookups hl
685 where
686 hl.lookup_type='CA_CMA' and
687 upper(ltrim(rtrim(hl.meaning))) in
688 ('CALGARY','EDMONTON','HALIFAX','MONTREAL','REGINA','TORONTO',
689 'VANCOUVER','WINNIPEG')
690 minus
691 select
692 ltrim(rtrim(segment2))
693 from
694 per_ca_ee_report_lines
695 where
696 request_id=p_request_id and
697 ltrim(rtrim(context))='FORM13' and
698 ltrim(rtrim(segment1))='CMA';
699
700 cursor cur_province_notfound is
701 select
702 ltrim(rtrim(hl.meaning)) meaning
703 from
704 hr_lookups hl
705 where
706 hl.lookup_type='CA_PROVINCE'
707 minus
708 select
709 ltrim(rtrim(segment2))
710 from
711 per_ca_ee_report_lines
712 where
713 request_id=p_request_id and
714 ltrim(rtrim(context))='FORM14' and
715 ltrim(rtrim(segment1))='PROVINCE';
716 /*
717 cursor cur_naic_person is
718 select
719 count(distinct paf.person_id) count_naic_person,
720 hl.lookup_code lcode
721 from
722 hr_lookups hl,
723 hr_soft_coding_keyflex hsck ,
724 hr_organization_information hoi,
725 per_assignments_f paf,
726 per_people_f ppf,
727 per_person_types ppt,
728 per_jobs pj,
729 hr_lookups hl1
730 where
731 (
732 (
733 p_naic_code is not null and
734 hl.lookup_type='NAIC' and
735 (
736 (
737 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
738 hsck.segment6 is not null and
739 hsck.segment6 = p_naic_code and
740 hl.lookup_code = hsck.segment6
741 )
742 OR
743 (
744 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
745 hsck.segment6 is null and
746 hoi.org_information8 is not null and
747 hl.lookup_code=hoi.org_information8 and
748 hoi.org_information8 = p_naic_code and
749 hsck.segment1 = to_char(hoi.organization_id) and
750 hoi.org_information_context = 'Canada Employer Identification'
751 )
752 )
753 )
754 OR
755 (
756 p_naic_code is null and
757 hl.lookup_type='NAIC' and
758 (
759 (
760 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
761 hsck.segment6 is not null and
762 hl.lookup_code = hsck.segment6
763 )
764 OR
765 (
766 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
767 hsck.segment6 is null and
768 hoi.org_information8 is not null and
769 hl.lookup_code=hoi.org_information8 and
770 hsck.segment1 = to_char(hoi.organization_id) and
771 hoi.org_information_context = 'Canada Employer Identification'
772 )
773 )
774 )
775 ) and
776 p_date_all_emp between
777 paf.effective_start_date and
778 paf.effective_end_date and
779 paf.business_group_id = p_business_group_id and
780 paf.primary_flag = 'Y' and
781 paf.job_id = pj.job_id and
782 pj.job_information_category = 'CA' and
783 pj.job_information1 = hl1.lookup_code and
784 hl1.lookup_type = 'EEOG' and
785 paf.person_id=ppf.person_id and
786 p_date_all_emp between
787 ppf.effective_start_date and
788 ppf.effective_end_date and
789 ppf.person_type_id=ppt.person_type_id and
790 ppt.system_person_type='EMP' and
791 exists
792 (
793 select 'X'
794 from per_pay_proposals_v2 pppv
795 where pppv.business_group_id = p_business_group_id and
796 pppv.assignment_id = paf.assignment_id and
797 pppv.approved = 'Y' and
798 pppv.change_date <= l_year_end
799 ) -- End of exists
800 group by hl.lookup_code
801 order by 1 desc;
802 */
803 v_max_naic varchar2(1) := 'Y';
804
805 cursor cur_hl_meaning(lc VARCHAR2) is
806 select
807 meaning
808 from
809 hr_lookups
810 where
811 lookup_type='NAIC' and
812 lookup_code=lc;
813
814 v_meaning hr_lookups.meaning%TYPE;
815 dummy varchar2(1);
816
817 cursor cur_legislation_info(p_lookup_type varchar2) is
818 select
819 pcli.lookup_code
820 from
821 pay_ca_legislation_info pcli
822 where
823 pcli.lookup_type = p_lookup_type;
824
825 v_legislation_info pay_ca_legislation_info.lookup_code%TYPE;
826 v_print varchar2(1);
827
828 cursor cur_gre_id(p_naic varchar2) is
829 select hou.organization_id
830 from
831 hr_organization_units hou,
832 hr_organization_information hoi
833 where
834 hoi.organization_id = hou.organization_id and
835 hou.business_group_id = p_business_group_id and
836 hoi.org_information_context = 'Canada Employer Identification' and
837 hoi.org_information8 is not null and
838 hoi.org_information8 = p_naic;
839
840 begin
841
842 --hr_utility.trace_on(1,'pg');
843
844 open cur_org_info;
845 fetch cur_org_info into
846 v_name,
847 v_address_line_1,
848 v_address_line_2,
849 v_address_line_3,
850 v_town_or_city,
851 v_region_1,
852 v_postal_code,
853 v_country,
854 v_organization_id,
855 v_short_name;
856 close cur_org_info;
857
858 insert into per_ca_ee_report_lines
859 ( request_id,
860 line_number,
861 context,
862 segment1,
863 segment2,
864 segment3,
865 segment4,
866 segment5,
867 segment6,
868 segment7,
869 segment8,
870 segment16) values
871 ( p_request_id,
872 per_ca_ee_extract_pkg.k,
873 'FORM11',
874 v_name,
875 v_address_line_1,
876 v_address_line_2,
877 v_address_line_3,
878 v_town_or_city,
879 v_region_1,
880 v_postal_code,
881 v_country,
882 v_short_name);
883
884 for i in cur_employee_info loop
885
886 update per_ca_ee_report_lines set
887 segment9 = i.ceo_name, -- CEO name
888 segment10 = i.ceo_position, -- and his Position
889 segment11 = i.contact_name, -- EE relevant personnel
890 segment12 = i.contact_position, -- and his Position
891 segment17 = i.contact_phone -- and Phone Number
892 where request_id = p_request_id and
893 context = 'FORM11' and
894 line_number = per_ca_ee_extract_pkg.k;
895 end loop;
896
897 -- The first NAIC will always have the maximum
898 -- value as the cur_naic_person is ordered by
899 -- count
900
901 /* open cur_legislation_info('EER1');
902 fetch cur_legislation_info
903 into v_legislation_info;
904 close cur_legislation_info; */
905
906 -- Calculate the employee totals for each naic
907 -- This improves performance by replacing the
908 -- cursor cur_naic_person
909
910 calc_naic_totals (p_naic_code,
911 p_date_all_emp,
912 p_business_group_id,
913 p_year);
914
915 IF v_sorted_naic.COUNT > 0 THEN
916
917 FOR i IN v_sorted_naic.first..v_sorted_naic.last LOOP
918
919 -- for i in cur_naic_person loop
920
921 per_ca_ee_extract_pkg.k := per_ca_ee_extract_pkg.k + 1;
922
923 open cur_hl_meaning(v_sorted_naic(i));
924 fetch cur_hl_meaning into v_meaning;
925 close cur_hl_meaning;
926
927 /* if i.count_naic_person > to_number(v_legislation_info) then
928 v_max_naic := 'Y';
929 else
930 v_max_naic := 'N';
934 v_max_naic := 'Y';
931 end if;
932
933 if i = 1 then
935 end if; */
936
937 insert into per_ca_ee_report_lines
938 (
939 request_id,
940 line_number,
941 context,
942 segment1,
943 segment2,
944 segment3,
945 segment4,
946 segment5
947 )
948 values
949 (
950 p_request_id,
951 per_ca_ee_extract_pkg.k,
952 'FORM12',
953 'NAIC',
954 v_meaning,
955 -- i.count_naic_person,
956 -- i.lcode,
957 v_sorted_naic_count(i),
958 v_sorted_naic(i),
959 v_max_naic
960 );
961
962 v_max_naic := 'N';
963
964 for gre_id in cur_gre_id(v_sorted_naic(i)) loop
965
966 insert into per_ca_ee_report_lines
967 (
968 request_id,
969 line_number,
970 context,
971 segment1,
972 segment2,
973 segment3
974 )
975 values
976 (
977 p_request_id,
978 per_ca_ee_extract_pkg.k,
979 'FORM13',
980 'NAIC',
981 -- i.lcode,
982 v_sorted_naic(i),
983 gre_id.organization_id
984 );
985
986 end loop; -- End loop GRE ID
987
988 END LOOP; -- End loop cur_naic_person
989
990 END IF;
991
992 for i in cur_employment_category
993 loop
994
995 if i.employment_category = 'FR' then
996
997 update per_ca_ee_report_lines set
998 segment13 = i.count_category
999 where request_id = p_request_id and
1000 --line_number = per_ca_ee_extract_pkg.k and
1001 context = 'FORM11';
1002
1003 elsif i.employment_category = 'PR' then
1004
1005 update per_ca_ee_report_lines set
1006 segment14 = i.count_category
1007 where request_id = p_request_id and
1008 --line_number = per_ca_ee_extract_pkg.k and
1009 context = 'FORM11';
1010
1011
1012 elsif i.employment_category = 'PT' then
1013
1014 hr_utility.trace('Form1: Employment Category: ' || i.employment_category);
1015
1016 update per_ca_ee_report_lines set
1017 segment15 = i.count_category
1018 where request_id = p_request_id and
1019 --line_number = per_ca_ee_extract_pkg.k and
1020 context = 'FORM11';
1021
1022 end if;
1023
1024 end loop; -- End loop cur_emplyment_category
1025
1026
1027 for i in 1..2 loop
1028
1029 for l in cur_province_cma(i) loop
1030
1031 per_ca_ee_extract_pkg.k := per_ca_ee_extract_pkg.k + 1;
1032
1033 open cur_legislation_info('EER2');
1034 fetch cur_legislation_info
1035 into v_legislation_info;
1036 close cur_legislation_info;
1037
1038 if l.count_province_cma >= to_number(v_legislation_info) then
1039 v_print := 'Y';
1040 else
1041 v_print := 'N';
1042 end if;
1043
1044 insert into per_ca_ee_report_lines
1045 (request_id,
1046 line_number,
1047 context,
1048 segment1,
1049 segment2,
1050 segment3,
1051 segment4) values
1052 (p_request_id,
1053 per_ca_ee_extract_pkg.k,
1054 decode(i,1,'FORM14',2,'FORM13'),
1055 decode(i,1,'PROVINCE',2,'CMA'),
1056 l.meaning,
1057 l.count_province_cma,
1058 v_print);
1059
1060 end loop; -- End loop cur_cma_province
1061
1062 end loop; -- End loop CMA/Province
1063
1064 for i in cur_cma_notfound loop
1065
1066 per_ca_ee_extract_pkg.k := per_ca_ee_extract_pkg.k + 1;
1067
1068 insert into per_ca_ee_report_lines
1069 (request_id,
1070 line_number,
1071 context,
1072 segment1,
1073 segment2,
1074 segment3,
1075 segment4) values
1076 (p_request_id,
1077 per_ca_ee_extract_pkg.k,
1078 'FORM13',
1079 'CMA',
1080 i.meaning,
1081 0,
1082 'N');
1083
1084 end loop;
1085
1086 for i in cur_province_notfound loop
1087
1088 per_ca_ee_extract_pkg.k := per_ca_ee_extract_pkg.k + 1;
1089
1090 insert into per_ca_ee_report_lines
1091 (request_id,
1092 line_number,
1093 context,
1094 segment1,
1095 segment2,
1096 segment3,
1097 segment4) values
1098 (p_request_id,
1099 per_ca_ee_extract_pkg.k,
1100 'FORM14',
1101 'PROVINCE',
1102 i.meaning,
1103 0,
1104 'N');
1105
1106 end loop;
1107
1108 return 1;
1109
1110 end;
1111
1112 end form1;
1113
1114
1115 function form2n(p_business_group_id in number,
1116 p_request_id in number,
1117 p_year in varchar2,
1118 p_date_tmp_emp in date) return number is
1119
1120 --l_year_start date;
1121 l_year_end date;
1122
1123 begin
1124
1125 --l_year_start := trunc(to_date(p_year,'YYYY'),'Y');
1126 l_year_end := add_months(trunc(to_date(p_year,'YYYY'),'Y'), 12) -1;
1127
1128 declare
1129
1130 cursor cur_legislation_info(p_lookup_type varchar2) is
1131 select lookup_code
1132 from pay_ca_legislation_info
1133 where lookup_type = p_lookup_type;
1134
1135 v_leg_info pay_ca_legislation_info.lookup_code%TYPE;
1136
1137 cursor cur_naic is
1138 select
1139 pert.segment3 tot_number_emp,
1140 pert.segment4 naic_code,
1141 pert.segment5 max_naic_flag
1142 from
1143 per_ca_ee_report_lines pert
1144 where
1145 pert.request_id = p_request_id and
1146 --(pert.segment5 = 'Y' OR
1147 -- to_number(pert.segment3) >= to_number(v_leg_info)) and
1148 pert.context = 'FORM12' ;
1149
1150 v_tot_number_emp per_ca_ee_report_lines.segment3%TYPE;
1151 v_naic_code hr_lookups.lookup_code%TYPE;
1152 v_max_naic_flag varchar2(1);
1153
1154 cursor cur_min_max is select
1155 max(max_salary) max_salary,
1156 min(min_salary) min_salary,
1157 meaning meaning,
1158 employment_category employment_category
1159 from
1160 (
1161 select
1162 trunc(to_number(pppv.proposed_salary)) * ppb.pay_annualization_factor
1163 max_salary,
1164 trunc(to_number(pppv.proposed_salary)) * ppb.pay_annualization_factor
1165 min_salary,
1166 hl.meaning meaning,
1167 substr(paf.employment_category,1,2) employment_category
1168 from
1169 hr_lookups hl,
1170 per_jobs pj,
1171 per_pay_proposals_v2 pppv,
1172 per_people_f ppf,
1173 per_assignments_f paf,
1174 per_person_types ppt,
1175 hr_soft_coding_keyflex hsck,
1176 per_pay_bases ppb
1177 where
1178 hl.lookup_type='EEOG' and
1179 hl.lookup_code=pj.job_information1 and
1180 pj.job_information_category='CA' and
1181 pj.job_id=paf.job_id and
1182 paf.primary_flag = 'Y' and
1183 decode(paf.employment_category,'PT',p_date_tmp_emp,l_year_end) between
1184 paf.effective_start_date and
1185 paf.effective_end_date and
1186 paf.pay_basis_id = ppb.pay_basis_id and
1187 ppb.business_group_id = p_business_group_id and
1188 paf.person_id=ppf.person_id and
1189 paf.assignment_id=pppv.assignment_id and
1190 pppv.change_date = (select max(pppv2.change_date)
1191 from per_pay_proposals_v2 pppv2
1192 where pppv2.assignment_id = paf.assignment_id
1193 and pppv2.change_date <=
1194 decode(substr(paf.employment_category,1,2),
1195 'PT',p_date_tmp_emp,l_year_end)
1196 ) and
1197 ppf.person_type_id=ppt.person_type_id and
1198 decode(paf.employment_category,'PT',p_date_tmp_emp,l_year_end) between
1199 ppf.effective_start_date and
1200 ppf.effective_end_date and
1201 upper(ltrim(rtrim(ppt.system_person_type)))='EMP' and
1202 ppf.business_group_id=p_business_group_id and
1203 paf.employment_category is not null and
1204 paf.employment_category in ('FR','PR','PT') and
1205 (
1206 (
1207 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
1208 hsck.segment6 is not null and
1209 hsck.segment6 = v_naic_code OR
1210 hsck.segment6 in ( select segment4
1211 from per_ca_ee_report_lines
1212 where request_id = p_request_id and
1213 context = 'FORM12' and
1214 to_number(segment3) <= to_number(v_leg_info) and
1215 v_max_naic_flag = 'Y')
1216 )
1217 OR
1218 (
1219 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
1220 hsck.segment6 is null and
1221 hsck.segment1 in (select segment3
1222 from per_ca_ee_report_lines
1223 where request_id = p_request_id and
1224 context = 'FORM13' and
1225 segment1 = 'NAIC' and
1226 segment2 = v_naic_code OR
1227 segment2 in
1228 ( select segment4
1229 from per_ca_ee_report_lines
1230 where request_id = p_request_id and
1231 context = 'FORM12' and
1232 to_number(segment3)
1233 <= to_number(v_leg_info) and
1234 v_max_naic_flag = 'Y')
1235 )
1236 )
1237 )
1238 union all
1239 select
1240 trunc(to_number(pppv.proposed_salary)) * ppb.pay_annualization_factor
1241 max_salary,
1242 trunc(to_number(pppv.proposed_salary)) * ppb.pay_annualization_factor
1243 min_salary,
1244 hl.meaning meaning,
1245 'FR' employment_category
1246 from
1247 hr_lookups hl,
1248 per_jobs pj,
1249 per_pay_proposals_v2 pppv,
1250 per_people_f ppf,
1251 per_assignments_f paf,
1252 per_person_types ppt,
1253 hr_soft_coding_keyflex hsck,
1254 per_pay_bases ppb
1255 where
1256 hl.lookup_type='EEOG' and
1257 hl.lookup_code=pj.job_information1 and
1258 pj.job_information_category='CA' and
1259 pj.job_id=paf.job_id and
1260 paf.primary_flag = 'Y' and
1261 l_year_end between
1262 paf.effective_start_date and
1263 paf.effective_end_date and
1264 paf.pay_basis_id = ppb.pay_basis_id and
1265 ppb.business_group_id = p_business_group_id and
1266 paf.person_id=ppf.person_id and
1267 paf.assignment_id=pppv.assignment_id and
1268 pppv.change_date = (select max(pppv2.change_date)
1269 from per_pay_proposals_v2 pppv2
1270 where pppv2.assignment_id = paf.assignment_id
1271 and pppv2.change_date <= l_year_end
1272 ) and
1273 ppf.person_type_id=ppt.person_type_id and
1274 l_year_end between
1275 ppf.effective_start_date and
1276 ppf.effective_end_date and
1277 upper(ltrim(rtrim(ppt.system_person_type)))='EMP' and
1278 ppf.business_group_id=p_business_group_id and
1279 ( paf.employment_category is null OR
1280 paf.employment_category not in ('FR','PR','PT')
1281 ) and
1282 (
1283 (
1284 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
1285 hsck.segment6 is not null and
1286 hsck.segment6 = v_naic_code OR
1287 hsck.segment6 in ( select segment4
1288 from per_ca_ee_report_lines
1289 where request_id = p_request_id and
1290 context = 'FORM12' and
1291 to_number(segment3) <= to_number(v_leg_info) and
1292 v_max_naic_flag = 'Y')
1293 )
1294 OR
1295 (
1296 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
1297 hsck.segment6 is null and
1298 hsck.segment1 in (select segment3
1299 from per_ca_ee_report_lines
1300 where request_id = p_request_id and
1301 context = 'FORM13' and
1302 segment1 = 'NAIC' and
1303 segment2 = v_naic_code OR
1304 segment2 in
1305 ( select segment4
1306 from per_ca_ee_report_lines
1307 where request_id = p_request_id and
1308 context = 'FORM12' and
1309 to_number(segment3)
1310 <= to_number(v_leg_info) and
1311 v_max_naic_flag = 'Y')
1312 )
1313 )
1314 )
1315 )
1316 group by meaning,employment_category
1317 order by meaning,employment_category;
1318
1319 v_max_salary number;
1320 v_min_salary number;
1321 v_meaning hr_lookups.meaning%TYPE;
1322 v_employment_category per_assignments_f.employment_category%TYPE;
1323
1324 j_flag varchar2(1) := 'F';
1325
1326 v_range number;
1327 v_q1_min number;
1328 v_q1_max number;
1329 v_q2_min number;
1330 v_q2_max number;
1331 v_q3_min number;
1332 v_q3_max number;
1333 v_q4_min number;
1334 v_q4_max number;
1335
1336 v_max_salary_range_min number;
1337 v_max_salary_range_max number;
1338 v_min_salary_range_min number;
1339 v_min_salary_range_max number;
1340
1341 cursor cur_count_total(i_range number)is select
1342 count(distinct paf.person_id) count_total,
1343 ppf.sex
1344 from
1345 hr_lookups hl,
1346 per_jobs pj,
1347 per_assignments_f paf,
1348 per_people_f ppf,
1349 per_pay_proposals_v2 pppv,
1350 per_person_types ppt,
1351 hr_soft_coding_keyflex hsck,
1352 per_pay_bases ppb
1353 where
1354 hl.lookup_type='EEOG' and
1355 upper(ltrim(rtrim(hl.meaning)))=upper(ltrim(rtrim(v_meaning))) and
1356 upper(ltrim(rtrim(hl.lookup_code)))
1357 = upper(ltrim(rtrim(pj.job_information1))) and
1358 upper(ltrim(rtrim(pj.job_information_category))) = 'CA' and
1359 pj.job_id=paf.job_id and
1360 paf.primary_flag = 'Y' and
1361 decode(substr(NVL(paf.employment_category,'FR'),1,2),
1362 'FR','FR','PR','PR','PT','PT','FR')
1363 = ltrim(rtrim(v_employment_category)) and
1364 decode(paf.employment_category,'PT',p_date_tmp_emp,l_year_end) between
1365 paf.effective_start_date and
1366 paf.effective_end_date and
1367 paf.person_id=ppf.person_id and
1368 ppf.person_type_id=ppt.person_type_id and
1369 decode(paf.employment_category,'PT',p_date_tmp_emp,l_year_end) between
1370 ppf.effective_start_date and
1371 ppf.effective_end_date and
1372 paf.pay_basis_id = ppb.pay_basis_id and
1373 ppb.business_group_id = p_business_group_id and
1374 paf.person_id=ppf.person_id and
1375 upper(ltrim(rtrim(ppt.system_person_type)))='EMP' and
1376 ppf.business_group_id=p_business_group_id and
1377 paf.assignment_id=pppv.assignment_id and
1378 pppv.change_date = (select max(pppv2.change_date)
1379 from per_pay_proposals_v2 pppv2
1380 where pppv2.assignment_id = paf.assignment_id
1381 and pppv2.change_date <=
1382 decode(substr(paf.employment_category,1,2),
1383 'PT',p_date_tmp_emp,l_year_end)
1384 ) and
1385 trunc(to_number(pppv.proposed_salary)) * ppb.pay_annualization_factor >=
1386 decode(i_range,1,v_q1_min,
1387 2,v_q2_min,
1388 3,v_q3_min,
1389 4,v_q4_min) and
1390 trunc(to_number(pppv.proposed_salary)) * ppb.pay_annualization_factor <=
1391 decode(i_range,1,v_q1_max,
1392 2,v_q2_max,
1393 3,v_q3_max,
1394 4,v_q4_max) and
1395 (
1396 (
1397 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
1398 hsck.segment6 is not null and
1399 hsck.segment6 = v_naic_code OR
1400 hsck.segment6 in ( select segment4
1401 from per_ca_ee_report_lines
1402 where request_id = p_request_id and
1403 context = 'FORM12' and
1404 to_number(segment3) <= to_number(v_leg_info) and
1405 v_max_naic_flag = 'Y')
1406 )
1407 OR
1408 (
1409 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
1410 hsck.segment6 is null and
1411 hsck.segment1 in (select segment3
1412 from per_ca_ee_report_lines
1413 where request_id = p_request_id and
1414 context = 'FORM13' and
1415 segment1 = 'NAIC' and
1416 segment2 = v_naic_code OR
1417 segment2 in
1418 ( select segment4
1419 from per_ca_ee_report_lines
1420 where request_id = p_request_id and
1421 context = 'FORM12' and
1422 to_number(segment3)
1423 <= to_number(v_leg_info) and
1424 v_max_naic_flag = 'Y')
1425 )
1426 )
1427 )
1428 group by ppf.sex
1429 order by ppf.sex;
1430
1431 v_count number(10);
1432 v_sex per_people_f.sex%TYPE;
1433 prev_employment_category per_assignments_f.employment_category%TYPE;
1434 prev_sex per_people_f.sex%TYPE;
1435 prev_j number := 0;
1436 prev_naic_code hr_lookups.lookup_code%TYPE;
1437 prev_meaning hr_lookups.meaning%TYPE;
1438
1439 cursor cur_count(range number,
1440 desig number) is
1441 select
1442 count(distinct paf.person_id) count,
1443 ppf.sex
1444 from
1445 hr_lookups hl,
1446 per_jobs pj,
1447 per_assignments_f paf,
1448 per_people_f ppf,
1449 per_pay_proposals_v2 pppv,
1450 per_person_types ppt,
1451 hr_soft_coding_keyflex hsck,
1452 per_pay_bases ppb
1453 where
1454 hl.lookup_type='EEOG' and
1455 upper(ltrim(rtrim(hl.meaning))) = upper(ltrim(rtrim(v_meaning))) and
1456 upper(ltrim(rtrim(hl.lookup_code)))
1457 = upper(ltrim(rtrim(pj.job_information1))) and
1458 upper(ltrim(rtrim(pj.job_information_category))) = 'CA' and
1459 pj.job_id=paf.job_id and
1460 paf.primary_flag = 'Y' and
1461 paf.pay_basis_id = ppb.pay_basis_id and
1462 decode(paf.employment_category,'PT',p_date_tmp_emp,l_year_end) between
1463 paf.effective_start_date and
1464 paf.effective_end_date and
1465 paf.person_id=ppf.person_id and
1466 ppf.person_type_id=ppt.person_type_id and
1467 decode(paf.employment_category,'PT',p_date_tmp_emp,l_year_end) between
1468 ppf.effective_start_date and
1469 ppf.effective_end_date and
1470 upper(ltrim(rtrim(ppt.system_person_type)))='EMP' and
1471 ppf.business_group_id=p_business_group_id and
1472 decode(desig,1,per_information5,
1473 2,per_information6,
1474 3,per_information7)='Y' and
1475 --substr(NVL(paf.employment_category,'FR'),1,2)=v_employment_category and
1476 decode(substr(NVL(paf.employment_category,'FR'),1,2),
1477 'FR','FR','PR','PR','PT','PT','FR') = v_employment_category and
1478 paf.assignment_id=pppv.assignment_id and
1479 pppv.change_date = (select max(pppv2.change_date)
1480 from per_pay_proposals_v2 pppv2
1481 where pppv2.assignment_id = paf.assignment_id
1482 and pppv2.change_date <=
1483 decode(substr(paf.employment_category,1,2),
1484 'PT',p_date_tmp_emp,l_year_end)
1485 ) and
1486 trunc(to_number(pppv.proposed_salary)) * ppb.pay_annualization_factor
1487 >= decode(range,1,v_q1_min,
1488 2,v_q2_min,
1489 3,v_q3_min,
1490 4,v_q4_min) and
1491 trunc(to_number(pppv.proposed_salary)) * ppb.pay_annualization_factor
1492 <= decode(range,1,v_q1_max,
1493 2,v_q2_max,
1494 3,v_q3_max,
1495 4,v_q4_max) and
1496 (
1497 (
1498 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
1499 hsck.segment6 is not null and
1500 hsck.segment6 = v_naic_code OR
1501 hsck.segment6 in ( select segment4
1502 from per_ca_ee_report_lines
1503 where request_id = p_request_id and
1504 context = 'FORM12' and
1505 to_number(segment3) <= to_number(v_leg_info) and
1506 v_max_naic_flag = 'Y')
1507
1508 )
1509 OR
1510 (
1511 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
1512 hsck.segment6 is null and
1513 hsck.segment1 in (select segment3
1514 from per_ca_ee_report_lines
1515 where request_id = p_request_id and
1516 context = 'FORM13' and
1517 segment1 = 'NAIC' and
1518 segment2 = v_naic_code OR
1519 segment2 in
1520 ( select segment4
1521 from per_ca_ee_report_lines
1522 where request_id = p_request_id and
1523 context = 'FORM12' and
1524 to_number(segment3)
1525 <= to_number(v_leg_info) and
1526 v_max_naic_flag = 'Y')
1527 )
1528 )
1529 )
1530 group by ppf.sex
1531 order by ppf.sex;
1532
1533 begin
1534
1535 open cur_legislation_info('EER1');
1536 fetch cur_legislation_info
1537 into v_leg_info;
1538 close cur_legislation_info;
1539
1540 for naic in cur_naic loop
1541
1542 v_tot_number_emp := naic.tot_number_emp;
1543 v_naic_code := naic.naic_code;
1544 v_max_naic_flag := naic.max_naic_flag;
1545
1546 if ( ( v_max_naic_flag = 'Y' ) OR
1547 (to_number(v_tot_number_emp) >= to_number(v_leg_info)) ) then
1548
1549 hr_utility.trace('Form2n starts Here !!!!!!!');
1550
1551 for i in cur_min_max loop
1552
1553 v_max_salary := nvl(to_number(i.max_salary),0);
1554 v_min_salary := nvl(to_number(i.min_salary),0);
1555 v_meaning := i.meaning;
1556 v_employment_category := i.employment_category;
1557
1558 hr_utility.trace('Form2: v_max_salary: ' || to_char(v_max_salary));
1559 hr_utility.trace('Form2: v_min_salary: ' || to_char(v_min_salary));
1560 hr_utility.trace('Form2: v_meaning: ' || v_meaning);
1561 hr_utility.trace('Form2: v_employment_category: '||v_employment_category);
1562
1563 -- To check the salary range in the predefined
1564 -- salary ranges
1565
1566 if v_max_salary >= 0 and v_max_salary < 5000 then
1567
1568 v_max_salary_range_min := 0;
1569 v_max_salary_range_max := 5000;
1570
1571 elsif v_max_salary >= 5000 and v_max_salary <= 9999 then
1572
1573 v_max_salary_range_min := 5000;
1574 v_max_salary_range_max := 9999;
1575
1576 elsif v_max_salary >= 10000 and v_max_salary <= 14999 then
1577
1578 v_max_salary_range_min := 10000;
1579 v_max_salary_range_max := 14999;
1580
1581 elsif v_max_salary >= 15000 and v_max_salary <= 19999 then
1582
1583 v_max_salary_range_min := 15000;
1584 v_max_salary_range_max := 19999;
1585
1586 elsif v_max_salary >= 20000 and v_max_salary <= 24999 then
1587
1588 v_max_salary_range_min := 20000;
1589 v_max_salary_range_max := 24999;
1590
1591 elsif v_max_salary >= 25000 and v_max_salary <= 29999 then
1592
1593 v_max_salary_range_min := 25000;
1594 v_max_salary_range_max := 29999;
1595
1596 elsif v_max_salary >= 30000 and v_max_salary <= 34999 then
1597
1598 v_max_salary_range_min := 30000;
1599 v_max_salary_range_max := 34999;
1600
1601 elsif v_max_salary >= 35000 and v_max_salary <= 39999 then
1602
1603 v_max_salary_range_min := 35000;
1604 v_max_salary_range_max := 39999;
1605
1606 elsif v_max_salary >= 40000 and v_max_salary <= 44999 then
1607
1608 v_max_salary_range_min := 40000;
1609 v_max_salary_range_max := 44999;
1610
1611 elsif v_max_salary >= 45000 and v_max_salary <= 49999 then
1612
1613 v_max_salary_range_min := 45000;
1614 v_max_salary_range_max := 49999;
1615
1616 elsif v_max_salary >= 50000 and v_max_salary <= 54999 then
1617
1618 v_max_salary_range_min := 50000;
1619 v_max_salary_range_max := 54999;
1620
1621 elsif v_max_salary >= 55000 and v_max_salary <= 59999 then
1622
1623 v_max_salary_range_min := 55000;
1624 v_max_salary_range_max := 59999;
1625
1626 elsif v_max_salary >= 60000 and v_max_salary <= 64999 then
1627
1628 v_max_salary_range_min := 60000;
1629 v_max_salary_range_max := 64999;
1630
1631 elsif v_max_salary >= 65000 and v_max_salary <= 69999 then
1632
1633 v_max_salary_range_min := 65000;
1634 v_max_salary_range_max := 69999;
1635
1636 elsif v_max_salary >= 70000 and v_max_salary <= 74999 then
1637
1638 v_max_salary_range_min := 70000;
1639 v_max_salary_range_max := 74999;
1640
1641 elsif v_max_salary >= 75000 and v_max_salary <= 79999 then
1642
1643 v_max_salary_range_min := 75000;
1644 v_max_salary_range_max := 79999;
1645
1646 elsif v_max_salary >= 80000 and v_max_salary <= 84999 then
1647
1648 v_max_salary_range_min := 80000;
1649 v_max_salary_range_max := 84999;
1650
1651 elsif v_max_salary >= 85000 and v_max_salary <= 89999 then
1652
1653 v_max_salary_range_min := 85000;
1654 v_max_salary_range_max := 89999;
1655
1656 elsif v_max_salary >= 90000 and v_max_salary <= 94999 then
1657
1658 v_max_salary_range_min := 90000;
1659 v_max_salary_range_max := 94999;
1660
1661 elsif v_max_salary >= 95000 and v_max_salary <= 99999 then
1662
1663 v_max_salary_range_min := 95000;
1664 v_max_salary_range_max := 99999;
1665
1666 elsif v_max_salary > 100000 then
1667 v_max_salary_range_min := 100000;
1668 v_max_salary_range_max := 9999999;
1669
1670 end if ;
1671
1672 if v_min_salary >= 0 and v_min_salary < 5000 then
1673
1674 v_min_salary_range_min := 0;
1675 v_min_salary_range_max := 5000;
1676
1677 elsif v_min_salary >= 5000 and v_min_salary <= 9999 then
1678
1679 v_min_salary_range_min := 5000;
1680 v_min_salary_range_max := 9999;
1681
1682 elsif v_min_salary >= 10000 and v_min_salary <= 14999 then
1683
1684 v_min_salary_range_min := 10000;
1685 v_min_salary_range_max := 14999;
1686
1687 elsif v_min_salary >= 15000 and v_min_salary <= 19999 then
1688
1689 v_min_salary_range_min := 15000;
1690 v_min_salary_range_max := 19999;
1691
1692 elsif v_min_salary >= 20000 and v_min_salary <= 24999 then
1693
1694 v_min_salary_range_min := 20000;
1695 v_min_salary_range_max := 24999;
1696
1697 elsif v_min_salary >= 25000 and v_min_salary <= 29999 then
1698
1699 v_min_salary_range_min := 25000;
1700 v_min_salary_range_max := 29999;
1701
1702 elsif v_min_salary >= 30000 and v_min_salary <= 34999 then
1703
1704 v_min_salary_range_min := 30000;
1705 v_min_salary_range_max := 34999;
1706
1707 elsif v_min_salary >= 35000 and v_min_salary <= 39999 then
1708
1709 v_min_salary_range_min := 35000;
1710 v_min_salary_range_max := 39999;
1711
1712 elsif v_min_salary >= 40000 and v_min_salary <= 44999 then
1713
1714 v_min_salary_range_min := 40000;
1715 v_min_salary_range_max := 44999;
1716
1717 elsif v_min_salary >= 45000 and v_min_salary <= 49999 then
1718
1719 v_min_salary_range_min := 45000;
1720 v_min_salary_range_max := 49999;
1721
1722 elsif v_min_salary >= 50000 and v_min_salary <= 54999 then
1723
1724 v_min_salary_range_min := 50000;
1725 v_min_salary_range_max := 54999;
1726
1727 elsif v_min_salary >= 55000 and v_min_salary <= 59999 then
1728
1729 v_min_salary_range_min := 55000;
1730 v_min_salary_range_max := 59999;
1731
1732 elsif v_min_salary >= 60000 and v_min_salary <= 64999 then
1733
1734 v_min_salary_range_min := 60000;
1735 v_min_salary_range_max := 64999;
1736
1737 elsif v_min_salary >= 65000 and v_min_salary <= 69999 then
1738
1739 v_min_salary_range_min := 65000;
1740 v_min_salary_range_max := 69999;
1741
1742 elsif v_min_salary >= 70000 and v_min_salary <= 74999 then
1743
1744 v_min_salary_range_min := 70000;
1745 v_min_salary_range_max := 74999;
1746
1747 elsif v_min_salary >= 75000 and v_min_salary <= 79999 then
1748
1749 v_min_salary_range_min := 75000;
1750 v_min_salary_range_max := 79999;
1751
1752 elsif v_min_salary >= 80000 and v_min_salary <= 84999 then
1753
1754 v_min_salary_range_min := 80000;
1755 v_min_salary_range_max := 84999;
1756
1757 elsif v_min_salary >= 85000 and v_min_salary <= 89999 then
1758
1759 v_min_salary_range_min := 85000;
1760 v_min_salary_range_max := 89999;
1761
1762 elsif v_min_salary >= 90000 and v_min_salary <= 94999 then
1763
1764 v_min_salary_range_min := 90000;
1765 v_min_salary_range_max := 94999;
1766
1767 elsif v_min_salary >= 95000 and v_min_salary <= 99999 then
1768
1769 v_min_salary_range_min := 95000;
1770 v_min_salary_range_max := 99999;
1771
1772 elsif v_min_salary > 100000 then
1773
1774 v_min_salary_range_min := 100000;
1775 v_min_salary_range_max := 9999999;
1776
1777 end if;
1778
1779 v_range := (nvl(v_max_salary,0)-nvl(v_min_salary,0))/4;
1780
1781 v_q1_min := nvl(v_min_salary,0);
1782 v_q1_max := v_q1_min + v_range;
1783
1784 v_q2_min := v_q1_max + 1;
1785 v_q2_max := v_q2_min + v_range - 1;
1786
1787 v_q3_min := v_q2_max + 1;
1788 v_q3_max := v_q3_min + v_range - 1;
1789
1790 v_q4_min := v_q3_max + 1;
1791 v_q4_max := v_q4_min + v_range -1;
1792
1793 hr_utility.trace('Form2: v_q1_min: ' ||to_char(v_q1_min));
1794 hr_utility.trace('Form2: v_q1_max: ' ||to_char(v_q1_max));
1795 hr_utility.trace('Form2: v_q2_min: ' ||to_char(v_q2_min));
1796 hr_utility.trace('Form2: v_q2_max: ' ||to_char(v_q2_max));
1797 hr_utility.trace('Form2: v_q3_min: ' ||to_char(v_q3_min));
1798 hr_utility.trace('Form2: v_q3_max: ' ||to_char(v_q3_max));
1799 hr_utility.trace('Form2: v_q4_min: ' ||to_char(v_q4_min));
1800 hr_utility.trace('Form2: v_q4_max: ' ||to_char(v_q4_max));
1801
1802 for j in 1..4 loop
1803
1804 j_flag := 'F';
1805
1806 for l in cur_count_total(j) loop
1807
1808 v_count := l.count_total;
1809 v_sex := l.sex;
1810
1811 hr_utility.trace('Form2n: '
1812 ||'EEOG ' || v_meaning
1813 ||'j = ' || to_char(j)
1814 ||'v_count = ' || to_char(v_count)
1815 ||'v_emp_cat = '|| v_employment_category
1816 ||'v_sex = ' || v_sex);
1817 if (
1818 (ltrim(rtrim(prev_employment_category)) <>
1819 ltrim(rtrim(v_employment_category))) or
1820 (ltrim(rtrim(prev_naic_code)) <> ltrim(rtrim(v_naic_code))) or
1821 (ltrim(rtrim(prev_meaning)) <> ltrim(rtrim(v_meaning))) or
1822 (prev_j <> j)
1823 ) then
1824
1825 per_ca_ee_extract_pkg.k := per_ca_ee_extract_pkg.k + 1;
1826
1827 hr_utility.trace('If .....');
1828
1829 insert into per_ca_ee_report_lines
1830 ( request_id,
1831 line_number,
1832 context,
1833 segment1,
1834 segment2,
1835 segment3,
1836 segment4,
1837 segment5,
1838 segment6,
1839 segment7,
1840 segment8,
1841 segment9,
1842 segment10,
1843 segment11,
1844 segment12,
1845 segment13,
1846 segment14,
1847 segment15,
1848 segment16,
1849 segment17,
1850 segment21) values
1851 (p_request_id,
1852 per_ca_ee_extract_pkg.k,
1853 'FORM2',
1854 'NATIONAL',
1855 v_meaning,
1856 v_employment_category,
1857 v_min_salary_range_min||'..'||
1858 v_min_salary_range_max||' '||
1859 v_max_salary_range_min||'..'||
1860 v_max_salary_range_max,
1861 to_char(j),
1862 nvl(v_count,0),
1863 decode(v_sex,'F',v_count,0),
1864 decode(v_sex,'M',v_count,0),
1865 '0',
1866 '0',
1867 '0',
1868 '0',
1869 '0',
1870 '0',
1871 '0',
1872 '0',
1873 '0',
1874 v_naic_code);
1875
1876 j_flag := 'T';
1877
1878 else
1879
1880 hr_utility.trace('else prev_employment_category ' || prev_employment_category);
1881
1882 if prev_employment_category = v_employment_category and
1883 prev_naic_code = v_naic_code and
1884 prev_meaning = v_meaning and
1885 prev_sex <> v_sex then
1886
1887 hr_utility.trace('Inside ........');
1888 if v_sex = 'M' then
1889
1890 hr_utility.trace('Update Male');
1891
1892 update per_ca_ee_report_lines set
1893 segment6=segment6 + nvl(v_count,0),
1894 segment8=nvl(v_count,0)
1895 where request_id=p_request_id and
1896 line_number=per_ca_ee_extract_pkg.k and
1897 segment1='NATIONAL' and
1898 segment21 = v_naic_code;
1899
1900 elsif v_sex = 'F' then
1901
1902 hr_utility.trace('Update Female');
1903
1904 update per_ca_ee_report_lines set
1905 segment6=segment6 + nvl(v_count,0),
1906 segment7=nvl(v_count,0)
1907 where request_id=p_request_id and
1908 line_number=per_ca_ee_extract_pkg.k and
1909 segment1='NATIONAL' and
1910 segment21 = v_naic_code;
1911
1912 end if;
1913 end if;
1914 end if;
1915
1916 prev_employment_category := v_employment_category;
1917 prev_naic_code := v_naic_code;
1918 prev_sex := v_sex;
1919 prev_meaning := v_meaning;
1920 prev_j := j;
1921
1922 end loop;
1923
1924 if j_flag = 'F' then
1925
1926 per_ca_ee_extract_pkg.k := per_ca_ee_extract_pkg.k + 1;
1927
1928 insert into per_ca_ee_report_lines
1929 ( request_id,
1930 line_number,
1931 context,
1932 segment1,
1933 segment2,
1934 segment3,
1935 segment4,
1936 segment5,
1937 segment6,
1938 segment7,
1939 segment8,
1940 segment9,
1941 segment10,
1942 segment11,
1943 segment12,
1944 segment13,
1945 segment14,
1946 segment15,
1947 segment16,
1948 segment17,
1949 segment21) values
1950 (p_request_id,
1951 per_ca_ee_extract_pkg.k,
1952 'FORM2',
1953 'NATIONAL',
1954 v_meaning,
1955 v_employment_category,
1956 v_min_salary_range_min||'..'||
1957 v_min_salary_range_max||' '||
1958 v_max_salary_range_min||'..'||
1959 v_max_salary_range_max,
1960 to_char(j),
1961 '0',
1962 '0',
1963 '0',
1964 '0',
1965 '0',
1966 '0',
1967 '0',
1968 '0',
1969 '0',
1970 '0',
1971 '0',
1972 '0',
1973 v_naic_code);
1974
1975 j_flag := 'T';
1976
1977 end if ;
1978
1979 end loop;
1980 ---------------------------------
1981 -- Updation designated Group --
1982 ---------------------------------
1983
1984 hr_utility.trace('Form2n: Before updation of designated Group');
1985 hr_utility.trace('Form2n: Before updation of desig Grp: v_meaning: '
1986 || v_meaning);
1987
1988 for j in 1..4 loop
1989
1990 for k in 1..3 loop
1991
1992 for l in cur_count(j,k) loop
1993
1994 hr_utility.trace('Form2n: Updation of designated Group');
1995
1996 if k = 1 then
1997
1998 if l.sex = 'F' then
1999
2000 update per_ca_ee_report_lines set
2001 segment9=nvl(segment9,0) + nvl(l.count,0),
2002 segment10=nvl(l.count,0)
2003 where
2004 request_id=p_request_id and
2005 context='FORM2' and
2006 segment1='NATIONAL' and
2007 upper(ltrim(rtrim(segment2)))=upper(ltrim(rtrim(v_meaning))) and
2008 upper(ltrim(rtrim(segment3)))
2009 =upper(ltrim(rtrim(v_employment_category))) and
2010 segment5=to_char(j) and
2011 segment21 = v_naic_code;
2012
2013 elsif l.sex = 'M' then
2014
2015 update per_ca_ee_report_lines set
2016 segment9=nvl(segment9,0) + nvl(l.count,0),
2017 segment11=nvl(l.count,0)
2018 where
2019 request_id=p_request_id and
2020 context='FORM2' and
2021 segment1='NATIONAL' and
2022 upper(ltrim(rtrim(segment2))) = upper(ltrim(rtrim(v_meaning))) and
2023 upper(ltrim(rtrim(segment3))) =
2024 upper(ltrim(rtrim(v_employment_category))) and
2025 segment5=to_char(j) and
2026 segment21 = v_naic_code;
2027
2028 end if;
2029
2030 elsif k = 2 then
2031
2032 if l.sex = 'F' then
2033
2034 update per_ca_ee_report_lines set
2035 segment12=nvl(segment12,0) + nvl(l.count,0),
2036 segment13=nvl(l.count,0)
2037 where
2038 request_id=p_request_id and
2039 context='FORM2' and
2040 segment1='NATIONAL' and
2041 upper(ltrim(rtrim(segment2)))
2042 =upper(ltrim(rtrim(v_meaning))) and
2043 upper(ltrim(rtrim(segment3)))
2044 =upper(ltrim(rtrim(v_employment_category))) and
2045 segment5=to_char(j) and
2046 segment21 = v_naic_code;
2047
2048 else
2049
2050 update per_ca_ee_report_lines set
2051 segment12=nvl(segment12,0) + nvl(l.count,0),
2052 segment14=nvl(l.count,0)
2053 where
2054 request_id=p_request_id and
2055 context='FORM2' and
2056 segment1='NATIONAL' and
2057 upper(ltrim(rtrim(segment2)))=upper(ltrim(rtrim(v_meaning))) and
2058 upper(ltrim(rtrim(segment3)))=upper(ltrim(rtrim(v_employment_category))) and
2059 segment5 =to_char(j) and
2060 segment21 = v_naic_code;
2061 end if;
2062
2063 elsif k = 3 then
2064
2065 if l.sex = 'F' then
2066 update per_ca_ee_report_lines set
2067 segment15=nvl(segment15,0) + nvl(l.count,0),
2068 segment16=nvl(l.count,0)
2069 where
2070 request_id=p_request_id and
2071 context = 'FORM2' and
2072 segment1 = 'NATIONAL' and
2073 upper(ltrim(rtrim(segment2))) = upper(ltrim(rtrim(v_meaning))) and
2074 upper(ltrim(rtrim(segment3)))
2075 = upper(ltrim(rtrim(v_employment_category))) and
2076 segment5 = to_char(j) and
2077 segment21 = v_naic_code;
2078 else
2079 update per_ca_ee_report_lines set
2080 segment15=nvl(segment15,0) + nvl(l.count,0),
2081 segment17=nvl(l.count,0)
2082 where
2083 request_id=p_request_id and
2084 context='FORM2' and
2085 segment1='NATIONAL' and
2086 upper(ltrim(rtrim(segment2))) =
2087 upper(ltrim(rtrim(v_meaning))) and
2088 upper(ltrim(rtrim(segment3)))
2089 = upper(ltrim(rtrim(v_employment_category))) and
2090 segment5=to_char(j) and
2091 segment21 = v_naic_code;
2092
2093 end if;
2094
2095 end if;
2096 end loop;
2097 end loop;
2098 end loop;
2099
2100 end loop;
2101
2102 prev_naic_code := v_naic_code;
2103
2104 end if; -- if v_max_naic_code = Y or segment3 greater than v_leg_info.
2105
2106 end loop; -- End loop cur_naic
2107
2108 return 1;
2109 end;
2110
2111 end form2n;
2112
2113
2114 function form2(p_business_group_id in number,
2115 p_request_id in number,
2116 p_year in varchar2,
2117 p_date_tmp_emp in date) return number is
2118
2119 --l_year_start date;
2120 l_year_end date;
2121
2122 begin
2123
2124 --l_year_start := trunc(to_date(p_year,'YYYY'),'Y');
2125 l_year_end := add_months(trunc(to_date(p_year,'YYYY'),'Y'), 12) -1;
2126
2127 declare
2128
2129 cursor cur_legislation_info(p_lookup_type varchar2) is
2130 select lookup_code
2131 from pay_ca_legislation_info
2132 where lookup_type = p_lookup_type;
2133
2134 v_leg_info pay_ca_legislation_info.lookup_code%TYPE;
2135
2136 cursor cur_naic is
2137 select
2138 pert.segment3 tot_number_emp,
2139 pert.segment4 naic_code,
2140 pert.segment5 max_naic_flag
2141 from
2142 per_ca_ee_report_lines pert
2143 where
2144 pert.request_id = p_request_id and
2145 --(pert.segment5 = 'Y' OR
2146 -- to_number(pert.segment3) >= to_number(v_leg_info)) and
2147 pert.context = 'FORM12' ;
2148
2149 v_tot_number_emp per_ca_ee_report_lines.segment3%TYPE;
2150 v_naic_code hr_lookups.lookup_code%TYPE;
2151 v_max_naic_flag varchar2(1);
2152
2153 cursor cur_min_max(cma_province_count number) is
2154 /* bug 10417732 : tuned the cursor to improve performance */
2155
2156 select
2157 max(max_salary) max_salary,
2158 min(min_salary) min_salary,
2159 meaning meaning,
2160 employment_category employment_category,
2161 cma_province cma_province
2162 from
2163 (
2164 select
2165 trunc(to_number(pppv.proposed_salary)) * ppb.pay_annualization_factor
2166 max_salary,
2167 trunc(to_number(pppv.proposed_salary)) * ppb.pay_annualization_factor min_salary,
2168 hl.meaning meaning,
2169 substr(paf.employment_category,1,2) employment_category,
2170 decode(CMA_PROVINCE_COUNT,1,hl1.region_1
2171 ,2,hl1.region_2) cma_province
2172 from
2173 hr_lookups hl,
2174 per_jobs pj,
2175 per_pay_proposals_v2 pppv,
2176 per_people_f ppf,
2177 per_assignments_f paf,
2178 hr_locations hl1,
2179 per_person_types ppt,
2180 per_ca_ee_report_lines pert,
2181 hr_lookups hl2,
2182 hr_soft_coding_keyflex hsck,
2183 per_pay_bases ppb
2184 where
2185 hl.lookup_type='EEOG' and
2186 hl.lookup_code=pj.job_information1 and
2187 pj.job_information_category='CA' and
2188 pj.job_id=paf.job_id and
2189 paf.primary_flag = 'Y' and
2190 decode(paf.employment_category,'PT',p_date_tmp_emp,l_year_end) between
2191 paf.effective_start_date and
2192 paf.effective_end_date and
2193 paf.employment_category is not null and
2194 paf.employment_category in ('FR','PR','PT') and
2195 paf.pay_basis_id = ppb.pay_basis_id and
2196 ppb.business_group_id = P_BUSINESS_GROUP_ID and
2197 paf.person_id=ppf.person_id
2198 and decode(paf.employment_category,'PT',p_date_tmp_emp,l_year_end) between ppf.effective_start_date and ppf.effective_end_date and
2199 paf.assignment_id=pppv.assignment_id
2200 and pppv.change_date = (select max(pppv2.change_date)
2201 from per_pay_proposals_v2 pppv2
2202 where pppv2.assignment_id = paf.assignment_id
2203 and paf.person_id=ppf.person_id
2204 and pppv2.change_date <=
2205 decode(substr(paf.employment_category,1,2),
2206 'PT',p_date_tmp_emp,l_year_end)
2207 ) and
2208 paf.location_id=hl1.location_id and
2209 ppf.person_type_id=ppt.person_type_id and
2210 upper(ltrim(rtrim(ppt.system_person_type)))='EMP' and
2211 ppf.business_group_id=p_business_group_id and
2212 hl2.lookup_type=decode(cma_province_count,1,'CA_PROVINCE'
2213 ,2,'CA_CMA') and
2214 hl2.lookup_code=decode(cma_province_count,1,hl1.region_1
2215 ,2,hl1.region_2) and
2216 --pert.segment4 = 'Y' and
2217 pert.request_id=p_request_id and
2218 pert.context=decode(cma_province_count,1,'FORM14'
2219 ,2,'FORM13') and
2220 pert.segment1=decode(cma_province_count,1,'PROVINCE'
2221 ,2,'CMA') and
2222 hl2.lookup_type=decode(cma_province_count,1,'CA_PROVINCE'
2223 ,2,'CA_CMA') and
2224 pert.segment2=hl2.meaning and
2225 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
2226 (
2227 (
2228 hsck.segment6 is not null and
2229 (hsck.segment6 = v_naic_code
2230 OR
2231 hsck.segment6 in ( select segment4
2232 from per_ca_ee_report_lines
2233 where request_id = p_request_id and
2234 context = 'FORM12' and
2235 to_number(segment3) < to_number(v_leg_info) and
2236 v_max_naic_flag = 'Y')
2237 )
2238 )
2239 OR
2240 (
2241 hsck.segment6 is null and
2242 hsck.segment1 in (select segment3
2243 from per_ca_ee_report_lines
2244 where request_id = p_request_id and
2245 context = 'FORM13' and
2246 segment1 = 'NAIC' and
2247 (
2248 segment2 = v_naic_code
2249 OR
2250 segment2 in
2251 ( select segment4
2252 from per_ca_ee_report_lines
2253 where request_id = p_request_id and
2254 context = 'FORM12' and
2255 to_number(segment3)
2256 < to_number(v_leg_info) and
2257 v_max_naic_flag = 'Y')
2258 )
2259 )
2260 )--pass2
2261 )
2262 union all --pass2
2263 select
2264 trunc(to_number(pppv.proposed_salary)) * ppb.pay_annualization_factor
2265 max_salary,
2266 trunc(to_number(pppv.proposed_salary)) * ppb.pay_annualization_factor
2267 min_salary,
2268 hl.meaning meaning,
2269 'FR' employment_category,
2270 decode(cma_province_count,1,hl1.region_1
2271 ,2,hl1.region_2) cma_province
2272 from
2273 hr_lookups hl,
2274 per_jobs pj,
2275 per_pay_proposals_v2 pppv,
2276 per_people_f ppf,
2277 per_assignments_f paf,
2278 hr_locations hl1,
2279 per_person_types ppt,
2280 per_ca_ee_report_lines pert,
2281 hr_lookups hl2,
2282 hr_soft_coding_keyflex hsck,
2283 per_pay_bases ppb
2284 where
2285 hl.lookup_type='EEOG' and
2286 hl.lookup_code=pj.job_information1 and
2287 pj.job_information_category='CA' and
2288 pj.job_id=paf.job_id and
2289 paf.primary_flag = 'Y' and
2290 l_year_end between
2291 paf.effective_start_date and
2292 paf.effective_end_date and
2293 (paf.employment_category is null OR
2294 paf.employment_category not in ('FR','PR','PT')
2295 ) and
2296 paf.pay_basis_id = ppb.pay_basis_id and
2297 ppb.business_group_id = p_business_group_id and
2298 paf.person_id=ppf.person_id and
2299 paf.assignment_id=pppv.assignment_id and
2300 pppv.change_date = (select max(pppv2.change_date)
2301 from per_pay_proposals_v2 pppv2
2302 where pppv2.assignment_id = paf.assignment_id
2303 and paf.person_id=ppf.person_id
2304 and pppv2.change_date <= l_year_end
2305 ) and
2306 l_year_end between
2307 ppf.effective_start_date and
2308 ppf.effective_end_date and
2309 paf.location_id=hl1.location_id and
2310 ppf.person_type_id=ppt.person_type_id and
2311 upper(ltrim(rtrim(ppt.system_person_type)))='EMP' and
2312 ppf.business_group_id=p_business_group_id and
2313 hl2.lookup_type=decode(cma_province_count,1,'CA_PROVINCE'
2314 ,2,'CA_CMA') and
2315 hl2.lookup_code=decode(cma_province_count,1,hl1.region_1
2316 ,2,hl1.region_2) and
2317 --pert.segment4 = 'Y' and
2318 pert.request_id=p_request_id and
2319 pert.context=decode(cma_province_count,1,'FORM14'
2320 ,2,'FORM13') and
2321 pert.segment1=decode(cma_province_count,1,'PROVINCE'
2322 ,2,'CMA') and
2323 hl2.lookup_type=decode(cma_province_count,1,'CA_PROVINCE'
2324 ,2,'CA_CMA') and
2325 pert.segment2=hl2.meaning and
2326 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
2327 (
2328 (
2329 hsck.segment6 is not null and
2330 (hsck.segment6 = v_naic_code
2331 OR
2332 hsck.segment6 in ( select segment4
2333 from per_ca_ee_report_lines
2334 where request_id = p_request_id and
2335 context = 'FORM12' and
2336 to_number(segment3) < to_number(v_leg_info) and
2337 v_max_naic_flag = 'Y')
2338 )
2339 )
2340 OR
2341 (
2342 hsck.segment6 is null and
2343 hsck.segment1 in (select segment3
2344 from per_ca_ee_report_lines
2345 where request_id = p_request_id and
2346 context = 'FORM13' and
2347 segment1 = 'NAIC' and
2348 (
2349 segment2 = v_naic_code
2350 OR
2351 segment2 in
2352 ( select segment4
2353 from per_ca_ee_report_lines
2354 where request_id = p_request_id and
2355 context = 'FORM12' and
2356 to_number(segment3)
2357 < to_number(v_leg_info) and
2358 v_max_naic_flag = 'Y')
2359 )
2360 )
2361 )
2362 )
2363 )
2364 group by meaning,employment_category,cma_province
2365 order by meaning,employment_category,cma_province;
2366
2367 /* bug 10417732 end */
2368
2369 v_max_salary number;
2370 v_min_salary number;
2371 v_meaning hr_lookups.meaning%TYPE;
2372 v_employment_category per_assignments_f.employment_category%TYPE;
2373 v_cma_province hr_locations.region_1%TYPE;
2374
2375 j_flag varchar2(1) := 'F';
2376
2377 cursor cur_meaning(cp number) is
2378 select
2379 meaning
2380 from
2381 hr_lookups
2382 where
2383 upper(ltrim(rtrim(lookup_type)))=decode(cp,1,'CA_PROVINCE'
2384 ,2,'CA_CMA') and
2385 upper(ltrim(rtrim(lookup_code)))=upper(ltrim(rtrim(v_cma_province)));
2386
2387 v_meaning1 hr_lookups.meaning%TYPE;
2388 v_range number;
2389 v_q1_min number;
2390 v_q1_max number;
2391 v_q2_min number;
2392 v_q2_max number;
2393 v_q3_min number;
2394 v_q3_max number;
2395 v_q4_min number;
2396 v_q4_max number;
2397
2398 v_max_salary_range_min number;
2399 v_max_salary_range_max number;
2400 v_min_salary_range_min number;
2401 v_min_salary_range_max number;
2402
2403 cursor cur_count_total(i_range number,
2404 i_x number) is
2405 select
2406 count(distinct paf.person_id) count_total,
2407 ppf.sex --sex
2408 from
2409 hr_lookups hl,
2410 per_jobs pj,
2411 per_assignments_f paf,
2412 per_people_f ppf,
2413 per_pay_proposals_v2 pppv,
2414 hr_locations hl1,
2415 per_person_types ppt,
2416 hr_soft_coding_keyflex hsck,
2417 per_pay_bases ppb
2418 where
2419 hl.lookup_type='EEOG' and
2420 upper(ltrim(rtrim(hl.meaning)))=upper(ltrim(rtrim(v_meaning))) and
2421 upper(ltrim(rtrim(hl.lookup_code)))
2422 =upper(ltrim(rtrim(pj.job_information1))) and
2423 upper(ltrim(rtrim(pj.job_information_category))) = 'CA' and
2424 pj.job_id=paf.job_id and
2425 paf.primary_flag = 'Y' and
2426 decode(paf.employment_category,'PT',p_date_tmp_emp,l_year_end) between
2427 paf.effective_start_date and
2428 paf.effective_end_date and
2429 decode(substr(NVL(paf.employment_category,'FR'),1,2),
2430 'FR','FR','PR','PR','PT','PT','FR')
2431 = ltrim(rtrim(v_employment_category)) and
2432 /* substr(NVL(paf.employment_category,'FR'),1,2) =
2433 ltrim(rtrim(v_employment_category)) and */
2434 paf.person_id=ppf.person_id and
2435 decode(paf.employment_category,'PT',p_date_tmp_emp,l_year_end) between
2436 ppf.effective_start_date and
2437 ppf.effective_end_date and
2438 paf.pay_basis_id = ppb.pay_basis_id and
2439 ppb.business_group_id = p_business_group_id and
2440 ppf.person_type_id=ppt.person_type_id and
2441 upper(ltrim(rtrim(ppt.system_person_type)))='EMP' and
2442 ppf.business_group_id=p_business_group_id and
2443 paf.location_id=hl1.location_id and
2444 decode(i_x,1,hl1.region_1,
2445 2,hl1.region_2) = v_cma_province and
2446 paf.assignment_id=pppv.assignment_id and
2447 pppv.change_date = (select max(pppv2.change_date)
2448 from per_pay_proposals_v2 pppv2
2449 where pppv2.assignment_id = paf.assignment_id
2450 and pppv2.change_date <=
2451 decode(substr(paf.employment_category,1,2),
2452 'PT',p_date_tmp_emp,l_year_end)
2453 ) and
2454 trunc(to_number(pppv.proposed_salary)) * ppb.pay_annualization_factor
2455 >= decode(i_range,1,v_q1_min,
2456 2,v_q2_min,
2457 3,v_q3_min,
2458 4,v_q4_min) and
2459 trunc(to_number(pppv.proposed_salary)) * ppb.pay_annualization_factor
2460 <= decode(i_range,1,v_q1_max,
2461 2,v_q2_max,
2462 3,v_q3_max,
2463 4,v_q4_max) and
2464 (
2465 (
2466 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
2467 hsck.segment6 is not null and
2468 hsck.segment6 = v_naic_code OR
2469 hsck.segment6 in ( select segment4
2470 from per_ca_ee_report_lines
2471 where request_id = p_request_id and
2472 context = 'FORM12' and
2473 to_number(segment3) < to_number(v_leg_info) and
2474 v_max_naic_flag = 'Y')
2475 )
2476 OR
2477 (
2478 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
2479 hsck.segment6 is null and
2480 hsck.segment1 in (select segment3
2481 from per_ca_ee_report_lines
2482 where request_id = p_request_id and
2483 context = 'FORM13' and
2484 segment1 = 'NAIC' and
2485 segment2 = v_naic_code OR
2486 segment2 in
2487 ( select segment4
2488 from per_ca_ee_report_lines
2489 where request_id = p_request_id and
2490 context = 'FORM12' and
2491 to_number(segment3)
2492 < to_number(v_leg_info) and
2493 v_max_naic_flag = 'Y')
2494 )
2495 )
2496 )
2497 group by ppf.sex
2498 order by ppf.sex;
2499
2500 v_count number(10);
2501 v_sex per_people_f.sex%TYPE;
2502 prev_employment_category per_assignments_f.employment_category%TYPE;
2503 prev_sex per_people_f.sex%TYPE;
2504 prev_j number := 0;
2505 prev_cma_province hr_locations.region_1%TYPE;
2506 prev_naic_code hr_lookups.lookup_code%TYPE;
2507 prev_meaning hr_lookups.meaning%TYPE;
2508
2509 cursor cur_count(range number,
2510 desig number,
2511 i_y number) is
2512 select
2513 count(distinct paf.person_id) count,
2514 ppf.sex --sex
2515 from
2516 hr_lookups hl,
2517 per_jobs pj,
2518 per_assignments_f paf,
2519 per_people_f ppf,
2520 per_pay_proposals_v2 pppv,
2521 hr_locations hl1,
2522 per_person_types ppt,
2523 hr_soft_coding_keyflex hsck,
2524 per_pay_bases ppb
2525 where
2526 hl.lookup_type='EEOG' and
2527 upper(ltrim(rtrim(hl.meaning)))=upper(ltrim(rtrim(v_meaning))) and
2528 upper(ltrim(rtrim(hl.lookup_code)))
2529 = upper(ltrim(rtrim(pj.job_information1))) and
2530 upper(ltrim(rtrim(pj.job_information_category))) = 'CA' and
2531 pj.job_id=paf.job_id and
2532 paf.primary_flag = 'Y' and
2533 decode(paf.employment_category,'PT',p_date_tmp_emp,l_year_end) between
2534 paf.effective_start_date and
2535 paf.effective_end_date and
2536 paf.pay_basis_id = ppb.pay_basis_id and
2537 ppb.business_group_id = p_business_group_id and
2538 paf.location_id=hl1.location_id and
2539 decode(i_y,1,hl1.region_1,
2540 2,hl1.region_2) = v_cma_province and
2541 paf.person_id=ppf.person_id and
2542 decode(paf.employment_category,'PT',p_date_tmp_emp,l_year_end) between
2543 ppf.effective_start_date and
2544 ppf.effective_end_date and
2545 ppf.person_type_id=ppt.person_type_id and
2546 upper(ltrim(rtrim(ppt.system_person_type)))='EMP' and
2547 ppf.business_group_id=p_business_group_id and
2548 decode(desig,1,per_information5,
2549 2,per_information6,
2550 3,per_information7)='Y' and
2551 --substr(NVL(paf.employment_category,'FR'),1,2)=v_employment_category and
2552 decode(substr(NVL(paf.employment_category,'FR'),1,2),
2553 'FR','FR','PR','PR','PT','PT','FR')
2554 = ltrim(rtrim(v_employment_category)) and
2555 paf.assignment_id=pppv.assignment_id and
2556 pppv.change_date = (select max(pppv2.change_date)
2557 from per_pay_proposals_v2 pppv2
2558 where pppv2.assignment_id = paf.assignment_id
2559 and pppv2.change_date <=
2560 decode(substr(paf.employment_category,1,2),
2561 'PT',p_date_tmp_emp,l_year_end)
2562 ) and
2563 trunc(to_number(pppv.proposed_salary)) * ppb.pay_annualization_factor
2564 >= decode(range,1,v_q1_min,
2565 2,v_q2_min,
2566 3,v_q3_min,
2567 4,v_q4_min) and
2568 trunc(to_number(pppv.proposed_salary)) * ppb.pay_annualization_factor
2569 <= decode(range,1,v_q1_max,
2570 2,v_q2_max,
2571 3,v_q3_max,
2572 4,v_q4_max) and
2573 (
2577 hsck.segment6 = v_naic_code OR
2574 (
2575 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
2576 hsck.segment6 is not null and
2578 hsck.segment6 in ( select segment4
2579 from per_ca_ee_report_lines
2580 where request_id = p_request_id and
2581 context = 'FORM12' and
2582 to_number(segment3) < to_number(v_leg_info) and
2583 v_max_naic_flag = 'Y')
2584 )
2585 OR
2586 (
2587 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
2588 hsck.segment6 is null and
2589 hsck.segment1 in (select segment3
2590 from per_ca_ee_report_lines
2591 where request_id = p_request_id and
2592 context = 'FORM13' and
2593 segment1 = 'NAIC' and
2594 segment2 = v_naic_code OR
2595 segment2 in
2596 ( select segment4
2597 from per_ca_ee_report_lines
2598 where request_id = p_request_id and
2599 context = 'FORM12' and
2600 to_number(segment3)
2601 < to_number(v_leg_info) and
2602 v_max_naic_flag = 'Y')
2603 )
2604 )
2605 )
2606 group by ppf.sex
2607 order by ppf.sex;
2608
2609 begin
2610
2611 open cur_legislation_info('EER1');
2612 fetch cur_legislation_info
2613 into v_leg_info;
2614 close cur_legislation_info;
2615
2616 hr_utility.trace('Form2 starts Here !!!');
2617
2618 for naic in cur_naic loop
2619
2620 v_tot_number_emp := naic.tot_number_emp;
2621 v_naic_code := naic.naic_code;
2622 v_max_naic_flag := naic.max_naic_flag;
2623
2624 if ( (v_max_naic_flag = 'Y') OR
2625 (to_number(v_tot_number_emp) >= to_number(v_leg_info)) ) then
2626
2627 for x in 1..2 loop
2628
2629 for i in cur_min_max(x) loop
2630
2631 hr_utility.trace('Form2: cur_min_max');
2632
2633 v_max_salary := nvl(to_number(i.max_salary),0);
2634 v_min_salary := nvl(to_number(i.min_salary),0);
2635 v_meaning := i.meaning;
2636 v_employment_category := i.employment_category;
2637 v_cma_province := i.cma_province;
2638
2639
2640 hr_utility.trace('Form2: v_cma_province: ' || v_cma_province);
2641 hr_utility.trace('Form2: v_employment_category: ' || v_employment_category);
2642 hr_utility.trace('Form2: v_meaning: ' || v_meaning);
2643
2644 open cur_meaning(x);
2645 fetch cur_meaning into v_meaning1;
2646 close cur_meaning;
2647
2648 -- To check the salary range in the predefined
2649 -- salary ranges
2650
2651 if v_max_salary >= 0 and v_max_salary < 5000 then
2652
2653 v_max_salary_range_min := 0;
2654 v_max_salary_range_max := 5000;
2655
2656 elsif v_max_salary >= 5000 and v_max_salary <= 9999 then
2657
2658 v_max_salary_range_min := 5000;
2659 v_max_salary_range_max := 9999;
2660
2661 elsif v_max_salary >= 10000 and v_max_salary <= 14999 then
2662
2663 v_max_salary_range_min := 10000;
2664 v_max_salary_range_max := 14999;
2665
2666 elsif v_max_salary >= 15000 and v_max_salary <= 19999 then
2667
2668 v_max_salary_range_min := 15000;
2669 v_max_salary_range_max := 19999;
2670
2671 elsif v_max_salary >= 20000 and v_max_salary <= 24999 then
2672
2673 v_max_salary_range_min := 20000;
2674 v_max_salary_range_max := 24999;
2675
2676 elsif v_max_salary >= 25000 and v_max_salary <= 29999 then
2677
2678 v_max_salary_range_min := 25000;
2679 v_max_salary_range_max := 29999;
2680
2681 elsif v_max_salary >= 30000 and v_max_salary <= 34999 then
2682
2683 v_max_salary_range_min := 30000;
2684 v_max_salary_range_max := 34999;
2685
2686 elsif v_max_salary >= 35000 and v_max_salary <= 39999 then
2687
2688 v_max_salary_range_min := 35000;
2689 v_max_salary_range_max := 39999;
2690
2691 elsif v_max_salary >= 40000 and v_max_salary <= 44999 then
2692
2693 v_max_salary_range_min := 40000;
2694 v_max_salary_range_max := 44999;
2695
2696 elsif v_max_salary >= 45000 and v_max_salary <= 49999 then
2697
2698 v_max_salary_range_min := 45000;
2699 v_max_salary_range_max := 49999;
2700
2701 elsif v_max_salary >= 50000 and v_max_salary <= 54999 then
2702
2703 v_max_salary_range_min := 50000;
2704 v_max_salary_range_max := 54999;
2705
2706 elsif v_max_salary >= 55000 and v_max_salary <= 59999 then
2707
2708 v_max_salary_range_min := 55000;
2709 v_max_salary_range_max := 59999;
2710
2711 elsif v_max_salary >= 60000 and v_max_salary <= 64999 then
2712
2713 v_max_salary_range_min := 60000;
2714 v_max_salary_range_max := 64999;
2715
2716 elsif v_max_salary >= 65000 and v_max_salary <= 69999 then
2717
2718 v_max_salary_range_min := 65000;
2719 v_max_salary_range_max := 69999;
2720
2721 elsif v_max_salary >= 70000 and v_max_salary <= 74999 then
2722
2723 v_max_salary_range_min := 70000;
2724 v_max_salary_range_max := 74999;
2725
2726 elsif v_max_salary >= 75000 and v_max_salary <= 79999 then
2727
2728 v_max_salary_range_min := 75000;
2729 v_max_salary_range_max := 79999;
2730
2734 v_max_salary_range_max := 84999;
2731 elsif v_max_salary >= 80000 and v_max_salary <= 84999 then
2732
2733 v_max_salary_range_min := 80000;
2735
2736 elsif v_max_salary >= 85000 and v_max_salary <= 89999 then
2737
2738 v_max_salary_range_min := 85000;
2739 v_max_salary_range_max := 89999;
2740
2741 elsif v_max_salary >= 90000 and v_max_salary <= 94999 then
2742
2743 v_max_salary_range_min := 90000;
2744 v_max_salary_range_max := 94999;
2745
2746 elsif v_max_salary >= 95000 and v_max_salary <= 99999 then
2747
2748 v_max_salary_range_min := 95000;
2749 v_max_salary_range_max := 99999;
2750
2751 elsif v_max_salary > 100000 then
2752
2753 v_max_salary_range_min := 100000;
2754 v_max_salary_range_max := 9999999;
2755
2756 end if ;
2757
2758 if v_min_salary >= 0 and v_min_salary < 5000 then
2759
2760 v_min_salary_range_min := 0;
2761 v_min_salary_range_max := 5000;
2762
2763 elsif v_min_salary >= 5000 and v_min_salary <= 9999 then
2764
2765 v_min_salary_range_min := 5000;
2766 v_min_salary_range_max := 9999;
2767
2768 elsif v_min_salary >= 10000 and v_min_salary <= 14999 then
2769
2770 v_min_salary_range_min := 10000;
2771 v_min_salary_range_max := 14999;
2772
2773 elsif v_min_salary >= 15000 and v_min_salary <= 19999 then
2774
2775 v_min_salary_range_min := 15000;
2776 v_min_salary_range_max := 19999;
2777
2778 elsif v_min_salary >= 20000 and v_min_salary <= 24999 then
2779
2780 v_min_salary_range_min := 20000;
2781 v_min_salary_range_max := 24999;
2782
2783 elsif v_min_salary >= 25000 and v_min_salary <= 29999 then
2784
2785 v_min_salary_range_min := 25000;
2786 v_min_salary_range_max := 29999;
2787
2788 elsif v_min_salary >= 30000 and v_min_salary <= 34999 then
2789
2790 v_min_salary_range_min := 30000;
2791 v_min_salary_range_max := 34999;
2792
2793 elsif v_min_salary >= 35000 and v_min_salary <= 39999 then
2794
2795 v_min_salary_range_min := 35000;
2796 v_min_salary_range_max := 39999;
2797
2798 elsif v_min_salary >= 40000 and v_min_salary <= 44999 then
2799
2800 v_min_salary_range_min := 40000;
2801 v_min_salary_range_max := 44999;
2802
2803 elsif v_min_salary >= 45000 and v_min_salary <= 49999 then
2804
2805 v_min_salary_range_min := 45000;
2806 v_min_salary_range_max := 49999;
2807
2808 elsif v_min_salary >= 50000 and v_min_salary <= 54999 then
2809
2810 v_min_salary_range_min := 50000;
2811 v_min_salary_range_max := 54999;
2812
2813 elsif v_min_salary >= 55000 and v_min_salary <= 59999 then
2814
2815 v_min_salary_range_min := 55000;
2816 v_min_salary_range_max := 59999;
2817
2818 elsif v_min_salary >= 60000 and v_min_salary <= 64999 then
2819
2820 v_min_salary_range_min := 60000;
2821 v_min_salary_range_max := 64999;
2822
2823 elsif v_min_salary >= 65000 and v_min_salary <= 69999 then
2824
2825 v_min_salary_range_min := 65000;
2826 v_min_salary_range_max := 69999;
2827
2828 elsif v_min_salary >= 70000 and v_min_salary <= 74999 then
2829
2830 v_min_salary_range_min := 70000;
2831 v_min_salary_range_max := 74999;
2832
2833 elsif v_min_salary >= 75000 and v_min_salary <= 79999 then
2834
2835 v_min_salary_range_min := 75000;
2836 v_min_salary_range_max := 79999;
2837
2838 elsif v_min_salary >= 80000 and v_min_salary <= 84999 then
2839
2840 v_min_salary_range_min := 80000;
2841 v_min_salary_range_max := 84999;
2842
2843 elsif v_min_salary >= 85000 and v_min_salary <= 89999 then
2844
2845 v_min_salary_range_min := 85000;
2846 v_min_salary_range_max := 89999;
2847
2848 elsif v_min_salary >= 90000 and v_min_salary <= 94999 then
2849
2850 v_min_salary_range_min := 90000;
2851 v_min_salary_range_max := 94999;
2852
2853 elsif v_min_salary >= 95000 and v_min_salary <= 99999 then
2854
2855 v_min_salary_range_min := 95000;
2856 v_min_salary_range_max := 99999;
2857
2858 elsif v_min_salary > 100000 then
2859
2860 v_min_salary_range_min := 100000;
2861 v_min_salary_range_max := 9999999;
2862
2863 end if;
2864
2865 v_range := (nvl(v_max_salary,0)-nvl(v_min_salary,0))/4;
2866
2867 v_q1_min := nvl(v_min_salary,0);
2868 v_q1_max := v_q1_min + v_range;
2869
2870 v_q2_min := v_q1_max + 1;
2871 v_q2_max := v_q2_min + v_range - 1;
2872
2873 v_q3_min := v_q2_max + 1;
2874 v_q3_max := v_q3_min + v_range - 1;
2875
2876 v_q4_min := v_q3_max + 1;
2877 v_q4_max := v_q4_min + v_range -1;
2878
2879 for j in 1..4 loop
2880
2881 j_flag := 'F';
2882
2883 for l in cur_count_total(j,x) loop
2884
2885 v_count := l.count_total;
2886 v_sex := l.sex;
2887
2888 if
2889 (
2890 (ltrim(rtrim(prev_cma_province)) <> ltrim(rtrim(v_meaning1))) or
2891 (ltrim(rtrim(prev_naic_code)) <> ltrim(rtrim(v_naic_code))) or
2892 (ltrim(rtrim(prev_meaning)) <> ltrim(rtrim(v_meaning))) or
2893 (ltrim(rtrim(prev_employment_category)) <>
2894 ltrim(rtrim(v_employment_category))) or
2895 (prev_j <> j)
2896 ) then
2900 insert into per_ca_ee_report_lines
2897
2898 per_ca_ee_extract_pkg.k := per_ca_ee_extract_pkg.k + 1;
2899
2901 ( request_id,
2902 line_number,
2903 context,
2904 segment1,
2905 segment2,
2906 segment3,
2907 segment4,
2908 segment5,
2909 segment6,
2910 segment7,
2911 segment8,
2912 segment9,
2913 segment10,
2914 segment11,
2915 segment12,
2916 segment13,
2917 segment14,
2918 segment15,
2919 segment16,
2920 segment17,
2921 segment18,
2922 segment21) values
2923 ( p_request_id,
2924 per_ca_ee_extract_pkg.k,
2925 'FORM2',
2926 decode(x,1,'PROVINCE'
2927 ,2,'CMA'),
2928 v_meaning1,
2929 v_meaning,
2930 v_employment_category,
2931 v_min_salary_range_min||'..'||
2932 v_min_salary_range_max||' '||
2933 v_max_salary_range_min||'..'||
2934 v_max_salary_range_max,
2935 to_char(j),
2936 nvl(v_count,0),
2937 decode(v_sex,'F',v_count,0),
2938 decode(v_sex,'M',v_count,0),
2939 '0',
2940 '0',
2941 '0',
2942 '0',
2943 '0',
2944 '0',
2945 '0',
2946 '0',
2947 '0',
2948 v_naic_code) ;
2949
2950 j_flag := 'T';
2951 else
2952 if prev_cma_province = v_meaning1 and
2953 prev_employment_category = v_employment_category and
2954 prev_naic_code = v_naic_code and
2955 prev_meaning = v_meaning and
2956 prev_sex <> v_sex then
2957
2958 if v_sex = 'M' then
2959
2960 update per_ca_ee_report_lines set
2961 segment7=segment7 + nvl(v_count,0),
2962 segment9=nvl(v_count,0)
2963 where request_id=p_request_id and
2964 line_number=per_ca_ee_extract_pkg.k and
2965 segment1=decode(x,1,'PROVINCE',
2966 2,'CMA') and
2967 segment2=v_meaning1 and
2968 segment21 = v_naic_code;
2969
2970 elsif v_sex = 'F' then
2971
2972 update per_ca_ee_report_lines set
2973 segment7=segment7 + nvl(v_count,0),
2974 segment9=nvl(v_count,0)
2975 where request_id=p_request_id and
2976 line_number=per_ca_ee_extract_pkg.k and
2977 segment1 = decode(x,1,'PROVINCE',
2978 2,'CMA') and
2979 segment2 = v_meaning1 and
2980 segment21 = v_naic_code;
2981
2982 end if;
2983 end if;
2984 end if;
2985
2986 prev_cma_province := v_meaning1;
2987 prev_employment_category := v_employment_category;
2988 prev_sex := v_sex;
2989 prev_j := j;
2990 prev_naic_code := v_naic_code;
2991 prev_meaning := v_meaning;
2992
2993 end loop;
2994
2995
2996 if j_flag = 'F' then
2997
2998 per_ca_ee_extract_pkg.k := per_ca_ee_extract_pkg.k + 1;
2999
3000 insert into per_ca_ee_report_lines
3001 ( request_id,
3002 line_number,
3003 context,
3004 segment1,
3005 segment2,
3006 segment3,
3007 segment4,
3008 segment5,
3009 segment6,
3010 segment7,
3011 segment8,
3012 segment9,
3013 segment10,
3014 segment11,
3015 segment12,
3016 segment13,
3017 segment14,
3018 segment15,
3019 segment16,
3020 segment17,
3021 segment18,
3022 segment21) values
3023 ( p_request_id,
3024 per_ca_ee_extract_pkg.k,
3025 'FORM2',
3026 decode(x,1,'PROVINCE'
3027 ,2,'CMA'),
3028 v_meaning1,
3029 v_meaning,
3030 v_employment_category,
3031 v_min_salary_range_min||'..'||
3032 v_min_salary_range_max||' '||
3033 v_max_salary_range_min||'..'||
3034 v_max_salary_range_max,
3035 to_char(j),
3036 '0',
3037 '0',
3038 '0',
3039 '0',
3040 '0',
3041 '0',
3042 '0',
3043 '0',
3044 '0',
3045 '0',
3046 '0',
3047 '0',
3048 v_naic_code);
3049
3050 j_flag := 'T';
3051
3052 end if ;
3053
3054 end loop;
3055 ---------------------------------
3056 -- Updation designated Group --
3057 ---------------------------------
3058
3059 for j in 1..4 loop
3060
3061 for k in 1..3 loop
3062
3063 for l in cur_count(j,k,x) loop
3064
3065 if k = 1 then
3066
3067 if l.sex = 'F' then
3068
3069 update per_ca_ee_report_lines set
3070 segment10=nvl(segment10,0) + nvl(l.count,0),
3071 segment11=nvl(l.count,0)
3072 where
3073 request_id=p_request_id and
3074 context='FORM2' and
3075 ltrim(rtrim(segment1))=decode(x,1,'PROVINCE'
3076 ,2,'CMA') and
3077 ltrim(rtrim(segment2))=ltrim(rtrim(v_meaning1)) and
3078 upper(ltrim(rtrim(segment3)))=upper(ltrim(rtrim(v_meaning))) and
3082 segment21 = v_naic_code;
3079 upper(ltrim(rtrim(segment4)))
3080 =upper(ltrim(rtrim(v_employment_category))) and
3081 segment6=to_char(j) and
3083
3084 elsif l.sex = 'M' then
3085
3086 update per_ca_ee_report_lines set
3087 segment10=nvl(segment10,0) + nvl(l.count,0),
3088 segment12=nvl(l.count,0)
3089 where
3090 request_id=p_request_id and
3091 context='FORM2' and
3092 ltrim(rtrim(segment1))=decode(x,1,'PROVINCE'
3093 ,2,'CMA') and
3094 ltrim(rtrim(segment2))=ltrim(rtrim(v_meaning1)) and
3095 upper(ltrim(rtrim(segment3))) =
3096 upper(ltrim(rtrim(v_meaning))) and
3097 upper(ltrim(rtrim(segment4))) =
3098 upper(ltrim(rtrim(v_employment_category))) and
3099 segment6=to_char(j) and
3100 segment21 = v_naic_code;
3101
3102 end if;
3103
3104 elsif k = 2 then
3105
3106 if l.sex = 'F' then
3107
3108 update per_ca_ee_report_lines set
3109 segment13=nvl(segment13,0) + nvl(l.count,0),
3110 segment14=nvl(l.count,0)
3111 where
3112 request_id=p_request_id and
3113 context='FORM2' and
3114 ltrim(rtrim(segment1))=decode(x,1,'PROVINCE'
3115 ,2,'CMA') and
3116 ltrim(rtrim(segment2))=ltrim(rtrim(v_meaning1)) and
3117 upper(ltrim(rtrim(segment3)))=upper(ltrim(rtrim(v_meaning))) and
3118 upper(ltrim(rtrim(segment4)))=
3119 upper(ltrim(rtrim(v_employment_category))) and
3120 segment6=to_char(j) and
3121 segment21 = v_naic_code;
3122 else
3123
3124 update per_ca_ee_report_lines set
3125 segment13=nvl(segment13,0) + nvl(l.count,0),
3126 segment15=nvl(l.count,0)
3127 where
3128 request_id=p_request_id and
3129 context='FORM2' and
3130 ltrim(rtrim(segment1))=decode(x,1,'PROVINCE'
3131 ,2,'CMA') and
3132 ltrim(rtrim(segment2))=ltrim(rtrim(v_meaning1)) and
3133 upper(ltrim(rtrim(segment3))) = upper(ltrim(rtrim(v_meaning))) and
3134 upper(ltrim(rtrim(segment4))) =
3135 upper(ltrim(rtrim(v_employment_category))) and
3136 segment6=to_char(j) and
3137 segment21 = v_naic_code;
3138
3139 end if;
3140
3141 elsif k = 3 then
3142
3143 if l.sex = 'F' then
3144
3145 update per_ca_ee_report_lines set
3146 segment16=nvl(segment16,0) + nvl(l.count,0),
3147 segment17=nvl(l.count,0)
3148 where
3149 request_id=p_request_id and
3150 context='FORM2' and
3151 ltrim(rtrim(segment1))=decode(x,1,'PROVINCE'
3152 ,2,'CMA') and
3153 ltrim(rtrim(segment2))=ltrim(rtrim(v_meaning1)) and
3154 upper(ltrim(rtrim(segment3)))=upper(ltrim(rtrim(v_meaning))) and
3155 upper(ltrim(rtrim(segment4)))=
3156 upper(ltrim(rtrim(v_employment_category))) and
3157 segment6=to_char(j) and
3158 segment21 = v_naic_code;
3159
3160 else
3161
3162 update per_ca_ee_report_lines set
3163 segment16=nvl(segment16,0) + nvl(l.count,0),
3164 segment18=nvl(l.count,0)
3165 where
3166 request_id=p_request_id and
3167 context='FORM2' and
3168 ltrim(rtrim(segment1))=decode(x,1,'PROVINCE'
3169 ,2,'CMA') and
3170 ltrim(rtrim(segment2))=ltrim(rtrim(v_meaning1)) and
3171 upper(ltrim(rtrim(segment3)))=upper(ltrim(rtrim(v_meaning))) and
3172 upper(ltrim(rtrim(segment4))) =
3173 upper(ltrim(rtrim(v_employment_category))) and
3174 segment6=to_char(j) and
3175 segment21 = v_naic_code;
3176
3177 end if;
3178
3179 end if;
3180 end loop;
3181 end loop;
3182 end loop;
3183
3184 end loop;
3185 end loop;
3186
3187 prev_naic_code := v_naic_code;
3188
3189 end if; -- if v_max_naic_code = Y or segment3 greater than v_leg_info.
3190
3191 end loop; -- End loop cur_naic
3192
3193 return 1;
3194 end;
3195
3196 end form2;
3197
3198
3199 function form3(p_business_group_id in number,
3200 p_request_id in number,
3201 p_year in varchar2,
3202 p_date_tmp_emp in date) return number is
3203
3204 --l_year_start date;
3205 l_year_end date;
3206
3207 begin
3208
3209 --l_year_start := trunc(to_date(p_year,'YYYY'),'Y');
3210 l_year_end := add_months(trunc(to_date(p_year,'YYYY'),'Y'), 12) -1;
3211
3212 declare
3213
3214 cursor cur_naic is
3215 select
3216 pert.segment4 naic_code
3217 from
3218 per_ca_ee_report_lines pert
3219 where
3220 pert.request_id = p_request_id and
3221 pert.context = 'FORM12';
3222
3223 v_naic_code hr_lookups.lookup_code%TYPE;
3224
3225 v_min_range number;
3226 v_max_range number;
3227 v_fr_min_range number;
3228 v_fr_max_range number;
3229
3230 cursor cur_count_total(cma_province_count number,
3231 range number) is
3232 select
3233 count(distinct count_total) count_total,
3237 from
3234 employment_category employment_category,
3235 sex sex,
3236 cma_province cma_province
3238 (
3239 select
3240 paf.person_id count_total,
3241 substr(paf.employment_category,1,2) employment_category,
3242 ppf.sex sex,
3243 decode(cma_province_count,1,hl1.region_1,2,hl1.region_2) cma_province
3244 from
3245 per_jobs pj,
3246 per_assignments_f paf,
3247 per_people_f ppf,
3248 per_pay_proposals_v2 pppv,
3249 per_person_types ppt,
3250 hr_locations hl1,
3251 per_ca_ee_report_lines pert,
3252 hr_lookups hl2,
3253 hr_soft_coding_keyflex hsck,
3254 per_pay_bases ppb
3255 where
3256 upper(ltrim(rtrim(pj.job_information_category))) = 'CA' and
3257 pj.job_id=paf.job_id and
3258 paf.primary_flag = 'Y' and
3259 decode(paf.employment_category,'PT',p_date_tmp_emp,l_year_end) between
3260 paf.effective_start_date and
3261 paf.effective_end_date and
3262 paf.employment_category is not null and
3263 substr(paf.employment_category,1,2) in ('FR','PR','PT') and
3264 paf.person_id=ppf.person_id and
3265 decode(paf.employment_category,'PT',p_date_tmp_emp,l_year_end) between
3266 ppf.effective_start_date and
3267 ppf.effective_end_date and
3268 paf.pay_basis_id = ppb.pay_basis_id and
3269 ppb.business_group_id = p_business_group_id and
3270 ppf.person_type_id=ppt.person_type_id and
3271 upper(ltrim(rtrim(ppt.system_person_type)))='EMP' and
3272 ppf.business_group_id=p_business_group_id and
3273 paf.location_id=hl1.location_id and
3274 hl2.lookup_type=decode(cma_province_count,1,'CA_PROVINCE'
3275 ,2,'CA_CMA') and
3276 hl2.lookup_code=decode(cma_province_count,1,hl1.region_1
3277 ,2,hl1.region_2) and
3278 --pert.segment4 = 'Y' and
3279 pert.request_id=p_request_id and
3280 pert.context=decode(cma_province_count,1,'FORM14'
3281 ,2,'FORM13') and
3282 pert.segment1=decode(cma_province_count,1,'PROVINCE'
3283 ,2,'CMA') and
3284 pert.segment2=hl2.meaning and
3285 paf.assignment_id=pppv.assignment_id and
3286 pppv.change_date = (select max(pppv2.change_date)
3287 from per_pay_proposals_v2 pppv2
3288 where pppv2.assignment_id = paf.assignment_id
3289 and pppv2.approved = 'Y'
3290 and pppv2.change_date <=
3291 decode(substr(paf.employment_category,1,2),
3292 'PT',p_date_tmp_emp,l_year_end)
3293 ) and
3294 trunc(to_number(pppv.proposed_salary)) * ppb.pay_annualization_factor >=
3295 decode(substr(paf.employment_category,1,2),
3296 'FR',v_fr_min_range,v_min_range) and
3297 trunc(to_number(pppv.proposed_salary)) * ppb.pay_annualization_factor <=
3298 decode(substr(paf.employment_category,1,2),
3299 'FR',v_fr_max_range,v_max_range) and
3300 (
3301 (
3302 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
3303 hsck.segment6 is not null and
3304 hsck.segment6 = v_naic_code
3305 )
3306 OR
3307 (
3308 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
3309 hsck.segment6 is null and
3310 hsck.segment1 in (select segment3
3311 from per_ca_ee_report_lines
3312 where request_id = p_request_id and
3313 context = 'FORM13' and
3314 segment1 = 'NAIC' and
3315 segment2 = v_naic_code)
3316 )
3317 )
3318 union all
3319 select
3320 paf.person_id count_total,
3321 'FR' employment_category,
3322 ppf.sex sex,
3323 decode(cma_province_count,1,hl1.region_1,2,hl1.region_2) cma_province
3324 from
3325 per_jobs pj,
3326 per_assignments_f paf,
3327 per_people_f ppf,
3328 per_pay_proposals_v2 pppv,
3329 per_person_types ppt,
3330 hr_locations hl1,
3331 per_ca_ee_report_lines pert,
3332 hr_lookups hl2,
3333 hr_soft_coding_keyflex hsck,
3334 per_pay_bases ppb
3335 where
3336 upper(ltrim(rtrim(pj.job_information_category))) = 'CA' and
3337 pj.job_id=paf.job_id and
3338 paf.primary_flag = 'Y' and
3339 l_year_end between
3340 paf.effective_start_date and
3341 paf.effective_end_date and
3342 (paf.employment_category is null OR
3343 substr(paf.employment_category,1,2) not in ('FR','PR','PT')) and
3344 paf.pay_basis_id = ppb.pay_basis_id and
3345 ppb.business_group_id = p_business_group_id and
3346 paf.person_id=ppf.person_id and
3347 l_year_end between
3348 ppf.effective_start_date and
3349 ppf.effective_end_date and
3350 ppf.person_type_id=ppt.person_type_id and
3351 upper(ltrim(rtrim(ppt.system_person_type)))='EMP' and
3352 ppf.business_group_id=p_business_group_id and
3353 paf.location_id=hl1.location_id and
3354 hl2.lookup_type=decode(cma_province_count,1,'CA_PROVINCE'
3355 ,2,'CA_CMA') and
3356 hl2.lookup_code=decode(cma_province_count,1,hl1.region_1
3357 ,2,hl1.region_2) and
3358 --pert.segment4 = 'Y' and
3359 pert.request_id=p_request_id and
3360 pert.context=decode(cma_province_count,1,'FORM14'
3361 ,2,'FORM13') and
3362 pert.segment1=decode(cma_province_count,1,'PROVINCE'
3363 ,2,'CMA') and
3364 pert.segment2=hl2.meaning and
3368 where pppv2.assignment_id = paf.assignment_id
3365 paf.assignment_id=pppv.assignment_id and
3366 pppv.change_date = (select max(pppv2.change_date)
3367 from per_pay_proposals_v2 pppv2
3369 and pppv2.approved = 'Y'
3370 and pppv2.change_date <= l_year_end
3371 ) and
3372 --to_number(pppv.proposed_salary) >= v_min_range and
3373 --pppv.change_date <= l_year_end and
3374 trunc(to_number(pppv.proposed_salary))* ppb.pay_annualization_factor
3375 >= v_fr_min_range and
3376 trunc(to_number(pppv.proposed_salary))* ppb.pay_annualization_factor
3377 <= v_fr_max_range and
3378 (
3379 (
3380 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
3381 hsck.segment6 is not null and
3382 hsck.segment6 = v_naic_code
3383 )
3384 OR
3385 (
3386 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
3387 hsck.segment6 is null and
3388 hsck.segment1 in (select segment3
3389 from per_ca_ee_report_lines
3390 where request_id = p_request_id and
3391 context = 'FORM13' and
3392 segment1 = 'NAIC' and
3393 segment2 = v_naic_code)
3394 )
3395 )
3396 )
3397 group by employment_category,sex,cma_province
3398 order by cma_province,employment_category,sex;
3399
3400 v_count number(10);
3401 v_sex per_people_f.sex%TYPE;
3402 v_employment_category per_assignments_f.employment_category%TYPE;
3403 prev_employment_category per_assignments_f.employment_category%TYPE;
3404 prev_sex per_people_f.sex%TYPE;
3405 prev_x number := 0;
3406 v_cma_province hr_locations.region_1%TYPE;
3407 prev_naic_code hr_lookups.lookup_code%TYPE;
3408
3409
3410 cursor cur_meaning(cp number) is
3411 select
3412 meaning from hr_lookups
3413 where
3414 upper(ltrim(rtrim(lookup_type)))=decode(cp,1,'CA_PROVINCE'
3415 ,2,'CA_CMA') and
3416 upper(ltrim(rtrim(lookup_code)))=upper(ltrim(rtrim(v_cma_province)));
3417
3418 v_meaning hr_lookups.meaning%TYPE;
3419 prev_meaning hr_lookups.meaning%TYPE;
3420
3421 cursor cur_count(cma_province_ct number,
3422 count number,
3423 desig number) is
3424 select
3425 count(distinct person_id) count,
3426 employment_category employment_category,
3427 sex sex,
3428 cma_province cma_province
3429 from
3430 (
3431 select
3432 paf.person_id person_id,
3433 substr(paf.employment_category,1,2) employment_category,
3434 ppf.sex sex,
3435 decode(cma_province_ct,1,hl1.region_1,2,hl1.region_2) cma_province
3436 from
3437 per_jobs pj,
3438 per_assignments_f paf,
3439 per_people_f ppf,
3440 per_pay_proposals_v2 pppv,
3441 per_person_types ppt,
3442 hr_locations hl1,
3443 per_ca_ee_report_lines pert,
3444 hr_lookups hl2,
3445 hr_soft_coding_keyflex hsck,
3446 per_pay_bases ppb
3447 where
3448 upper(ltrim(rtrim(pj.job_information_category))) = 'CA' and
3449 pj.job_id=paf.job_id and
3450 paf.primary_flag = 'Y' and
3451 decode(paf.employment_category,'PT',p_date_tmp_emp,l_year_end) between
3452 paf.effective_start_date and
3453 paf.effective_end_date and
3454 paf.employment_category is not null and
3455 substr(paf.employment_category,1,2) in ('FR','PR','PT') and
3456 paf.person_id=ppf.person_id and
3457 decode(paf.employment_category,'PT',p_date_tmp_emp,l_year_end) between
3458 ppf.effective_start_date and
3459 ppf.effective_end_date and
3460 paf.pay_basis_id = ppb.pay_basis_id and
3461 ppb.business_group_id = p_business_group_id and
3462 ppf.person_type_id=ppt.person_type_id and
3463 upper(ltrim(rtrim(ppt.system_person_type)))='EMP' and
3464 ppf.business_group_id=p_business_group_id and
3465 paf.location_id=hl1.location_id and
3466 hl2.lookup_type=decode(cma_province_ct,1,'CA_PROVINCE'
3467 ,2,'CA_CMA') and
3468 hl2.lookup_code=decode(cma_province_ct,1,hl1.region_1
3469 ,2,hl1.region_2) and
3470 --pert.segment4 = 'Y' and
3471 pert.request_id=p_request_id and
3472 pert.context=decode(cma_province_ct,1,'FORM14'
3473 ,2,'FORM13') and
3474 pert.segment1=decode(cma_province_ct,1,'PROVINCE'
3475 ,2,'CMA') and
3476 pert.segment2=hl2.meaning and
3477 decode(desig,1,per_information5,
3478 2,per_information6,
3479 3,per_information7)='Y' and
3480 substr(NVL(paf.employment_category,'FR'),1,2)=v_employment_category and
3481 paf.assignment_id=pppv.assignment_id and
3482 pppv.change_date = (select max(pppv2.change_date)
3483 from per_pay_proposals_v2 pppv2
3484 where pppv2.assignment_id = paf.assignment_id
3485 and pppv2.approved = 'Y'
3486 and pppv2.change_date <=
3487 decode(substr(paf.employment_category,1,2),
3488 'PT',p_date_tmp_emp,l_year_end)
3489 ) and
3490 trunc(to_number(pppv.proposed_salary)) * ppb.pay_annualization_factor >=
3491 decode(substr(paf.employment_category,1,2),
3492 'FR',v_fr_min_range,v_min_range) and
3496 (
3493 trunc(to_number(pppv.proposed_salary)) * ppb.pay_annualization_factor <=
3494 decode(substr(paf.employment_category,1,2),
3495 'FR',v_fr_max_range,v_max_range) and
3497 (
3498 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
3499 hsck.segment6 is not null and
3500 hsck.segment6 = v_naic_code
3501 )
3502 OR
3503 (
3504 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
3505 hsck.segment6 is null and
3506 hsck.segment1 in (select segment3
3507 from per_ca_ee_report_lines
3508 where request_id = p_request_id and
3509 context = 'FORM13' and
3510 segment1 = 'NAIC' and
3511 segment2 = v_naic_code)
3512 )
3513 )
3514 union all
3515 select
3516 paf.person_id person_id,
3517 'FR' employment_category,
3518 ppf.sex sex,
3519 decode(cma_province_ct,1,hl1.region_1,2,hl1.region_2) cma_province
3520 from
3521 per_jobs pj,
3522 per_assignments_f paf,
3523 per_people_f ppf,
3524 per_pay_proposals_v2 pppv,
3525 per_person_types ppt,
3526 hr_locations hl1,
3527 per_ca_ee_report_lines pert,
3528 hr_lookups hl2,
3529 hr_soft_coding_keyflex hsck,
3530 per_pay_bases ppb
3531 where
3532 upper(ltrim(rtrim(pj.job_information_category))) = 'CA' and
3533 pj.job_id=paf.job_id and
3534 paf.primary_flag = 'Y' and
3535 l_year_end between
3536 paf.effective_start_date and
3537 paf.effective_end_date and
3538 (paf.employment_category is null OR
3539 substr(paf.employment_category,1,2) not in ('FR','PR','PT')) and
3540 paf.person_id=ppf.person_id and
3541 l_year_end between
3542 paf.effective_start_date and
3543 paf.effective_end_date and
3544 ppf.person_type_id=ppt.person_type_id and
3545 upper(ltrim(rtrim(ppt.system_person_type)))='EMP' and
3546 ppf.business_group_id=p_business_group_id and
3547 paf.location_id=hl1.location_id and
3548 hl2.lookup_type=decode(cma_province_ct,1,'CA_PROVINCE'
3549 ,2,'CA_CMA') and
3550 hl2.lookup_code=decode(cma_province_ct,1,hl1.region_1
3551 ,2,hl1.region_2) and
3552 --pert.segment4 = 'Y' and
3553 pert.request_id=p_request_id and
3554 pert.context=decode(cma_province_ct,1,'FORM14'
3555 ,2,'FORM13') and
3556 pert.segment1=decode(cma_province_ct,1,'PROVINCE'
3557 ,2,'CMA') and
3558 pert.segment2=hl2.meaning and
3559 decode(desig,1,per_information5,
3560 2,per_information6,
3561 3,per_information7)='Y' and
3562 --substr(NVL(paf.employment_category,'FR'),1,2)=v_employment_category and
3563 paf.pay_basis_id = ppb.pay_basis_id and
3564 ppb.business_group_id = p_business_group_id and
3565 paf.assignment_id=pppv.assignment_id and
3566 pppv.change_date = (select max(pppv2.change_date)
3567 from per_pay_proposals_v2 pppv2
3568 where pppv2.assignment_id = paf.assignment_id
3569 and pppv2.approved = 'Y'
3570 and pppv2.change_date <= l_year_end
3571 ) and
3572 trunc(to_number(pppv.proposed_salary))
3573 * ppb.pay_annualization_factor >= v_fr_min_range and
3574 trunc(to_number(pppv.proposed_salary))
3575 * ppb.pay_annualization_factor <= v_fr_max_range and
3576 (
3577 (
3578 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
3579 hsck.segment6 is not null and
3580 hsck.segment6 = v_naic_code
3581 )
3582 OR
3583 (
3584 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
3585 hsck.segment6 is null and
3586 hsck.segment1 in (select segment3
3587 from per_ca_ee_report_lines
3588 where request_id = p_request_id and
3589 context = 'FORM13' and
3590 segment1 = 'NAIC' and
3591 segment2 = v_naic_code)
3592 )
3593 )
3594 )
3595 group by employment_category,sex,cma_province
3596 order by employment_category,sex,cma_province;
3597
3598 cursor cur_notfound(range varchar2,
3599 pc number,
3600 p_category varchar2) is
3601 select
3602 decode(pc,1,'PROVINCE','CMA') provcma,
3603 segment2 provcma_name,
3604 p_category emp_category,
3605 decode(p_category,'FR',v_fr_min_range|| ' - ' || v_fr_max_range,
3606 v_min_range || ' - ' || v_max_range)
3607 max_min_range
3608
3609 from
3610 per_ca_ee_report_lines
3611 where
3612 request_id = p_request_id and
3613 context=decode(pc,1,'FORM14','FORM13') and
3614 segment1 = decode(pc,1,'PROVINCE','CMA') and
3615 segment3 <> '0'
3616 minus
3617 select
3618 segment1,
3619 segment2,
3620 segment4,
3621 segment3
3622 from
3623 per_ca_ee_report_lines
3624 where
3625 request_id = p_request_id and
3626 context = 'FORM3' and
3627 segment1 = decode(pc,1,'PROVINCE','CMA') and
3628 segment21 = v_naic_code;
3629
3630 cursor cur_count_national is
3631 select
3632 segment3,
3633 segment4,
3634 sum(to_number(segment5)) segment5,
3638 sum(to_number(segment9)) segment9,
3635 sum(to_number(segment6)) segment6,
3636 sum(to_number(segment7)) segment7,
3637 sum(to_number(segment8)) segment8,
3639 sum(to_number(segment10)) segment10,
3640 sum(to_number(segment11)) segment11,
3641 sum(to_number(segment12)) segment12,
3642 sum(to_number(segment13)) segment13,
3643 sum(to_number(segment14)) segment14,
3644 sum(to_number(segment15)) segment15,
3645 sum(to_number(segment16)) segment16
3646 from
3647 per_ca_ee_report_lines
3648 where
3649 request_id = p_request_id and
3650 context = 'FORM3' and
3651 segment1 = 'PROVINCE' and
3652 segment21 = v_naic_code
3653 group by segment3,segment4;
3654
3655 pc_count number;
3656 emp_cat varchar2(2);
3657
3658 begin
3659
3660 hr_utility.trace('Form3 starts here !!!!!');
3661
3662 for naic in cur_naic loop
3663
3664 v_naic_code := naic.naic_code;
3665
3666 for i in 1..2 loop
3667 for x in 1..14 loop
3668
3669 if x = 1 then
3670
3671 v_min_range := 0;
3672 v_max_range := 4999;
3673
3674 v_fr_min_range := 0;
3675 v_fr_max_range := 14999;
3676
3677 elsif x = 2 then
3678
3679 v_min_range := 5000;
3680 v_max_range := 7499;
3681
3682 v_fr_min_range := 15000;
3683 v_fr_max_range := 19999;
3684
3685 elsif x = 3 then
3686
3687 v_min_range := 7500;
3688 v_max_range := 9999;
3689
3690 v_fr_min_range := 20000;
3691 v_fr_max_range := 24999;
3692
3693 elsif x = 4 then
3694
3695 v_min_range := 10000;
3696 v_max_range := 12499;
3697
3698 v_fr_min_range := 25000;
3699 v_fr_max_range := 29999;
3700
3701 elsif x = 5 then
3702
3703 v_min_range := 12500;
3704 v_max_range := 14999;
3705
3706 v_fr_min_range := 30000;
3707 v_fr_max_range := 34999;
3708
3709 elsif x = 6 then
3710
3711 v_min_range := 15000;
3712 v_max_range := 17499;
3713
3714 v_fr_min_range := 35000;
3715 v_fr_max_range := 37499;
3716
3717 elsif x = 7 then
3718
3719 v_min_range := 17500;
3720 v_max_range := 19999;
3721
3722 v_fr_min_range := 37500;
3723 v_fr_max_range := 39999;
3724
3725 elsif x = 8 then
3726
3727 v_min_range := 20000;
3728 v_max_range := 22499;
3729
3730 v_fr_min_range := 40000;
3731 v_fr_max_range := 44999;
3732
3733 elsif x = 9 then
3734
3735 v_min_range := 22500;
3736 v_max_range := 24999;
3737
3738 v_fr_min_range := 45000;
3739 v_fr_max_range := 49999;
3740
3741 elsif x = 10 then
3742
3743 v_min_range := 25000;
3744 v_max_range := 29999;
3745
3746 v_fr_min_range := 50000;
3747 v_fr_max_range := 59999;
3748
3749 elsif x = 11 then
3750
3751 v_min_range := 30000;
3752 v_max_range := 34499;
3753
3754 v_fr_min_range := 60000;
3755 v_fr_max_range := 69999;
3756
3757 elsif x = 12 then
3758
3759 v_min_range := 35000;
3760 v_max_range := 39999;
3761
3762 v_fr_min_range := 70000;
3763 v_fr_max_range := 84999;
3764
3765 elsif x = 13 then
3766
3767 v_min_range := 40000;
3768 v_max_range := 49999;
3769
3770 v_fr_min_range := 85000;
3771 v_fr_max_range := 99999;
3772
3773 elsif x = 14 then
3774
3775 v_min_range := 50000;
3776 v_max_range := 9999999;
3777
3778 v_fr_min_range := 100000;
3779 v_fr_max_range := 9999999;
3780
3781 end if;
3782
3783 hr_utility.trace('v_min_range = '||to_char(v_min_range));
3784 hr_utility.trace('v_max_range = '||to_char(v_max_range));
3785 hr_utility.trace('cur_count_total = ');
3786
3787 for l in cur_count_total(i,x) loop
3788
3789 v_count := l.count_total;
3790 v_sex := l.sex;
3791 v_employment_category := l.employment_category;
3792 v_cma_province := l.cma_province;
3793
3794 hr_utility.trace('v_count = ' || to_char(v_count));
3795 hr_utility.trace('v_sex = '|| v_sex);
3796 hr_utility.trace('v_employment_category = ' || v_employment_category);
3797 hr_utility.trace('v_cma_province = '|| v_cma_province );
3798
3799 open cur_meaning(i);
3800 fetch cur_meaning into v_meaning;
3801 close cur_meaning;
3802
3803 if
3804 (
3805 (ltrim(rtrim(prev_meaning)) <> ltrim(rtrim(v_meaning))) or
3806 (ltrim(rtrim(prev_employment_category)) <>
3807 ltrim(rtrim(v_employment_category))) or
3808 (ltrim(rtrim(prev_naic_code)) <> ltrim(rtrim(v_naic_code))) or
3809 (prev_x <> x)
3810 ) then
3811
3812 hr_utility.trace('v_meaning = '|| v_meaning );
3813
3814 per_ca_ee_extract_pkg.k := per_ca_ee_extract_pkg.k + 1;
3815
3816 insert into per_ca_ee_report_lines
3817 ( request_id,
3818 line_number,
3819 context,
3820 segment1,
3821 segment2,
3822 segment3,
3823 segment4,
3824 segment5,
3825 segment6,
3826 segment7,
3827 segment8,
3828 segment9,
3829 segment10,
3830 segment11,
3834 segment15,
3831 segment12,
3832 segment13,
3833 segment14,
3835 segment16,
3836 segment21) values
3837 ( p_request_id,
3838 per_ca_ee_extract_pkg.k,
3839 'FORM3',
3840 decode(i,1,'PROVINCE',
3841 2,'CMA'),
3842 v_meaning,
3843 decode(v_employment_category,'FR',
3844 v_fr_min_range||' - '||v_fr_max_range,
3845 v_min_range||' - '||v_max_range),
3846 v_employment_category,
3847 nvl(v_count,0),
3848 decode(v_sex,'F',v_count,0),
3849 decode(v_sex,'M',v_count,0),
3850 0,
3851 0,
3852 0,
3853 0,
3854 0,
3855 0,
3856 0,
3857 0,
3858 0,
3859 v_naic_code) ;
3860
3861 else
3862 if prev_meaning = v_meaning and
3863 prev_employment_category = v_employment_category and
3864 prev_naic_code = v_naic_code and
3865 prev_x = x and
3866 prev_sex <> v_sex then
3867
3868 if v_sex = 'M' then
3869 update per_ca_ee_report_lines set
3870 segment5 = segment5 + nvl(v_count,0),
3871 segment7 = nvl(v_count,0)
3872 where
3873 request_id=p_request_id and
3874 line_number=per_ca_ee_extract_pkg.k and
3875 context = 'FORM3' and
3876 segment1 = decode(i,1,'PROVINCE',2,'CMA') and
3877 segment2 = v_meaning and
3878 segment3 = decode(v_employment_category,'FR',
3879 v_fr_min_range|| ' - '||v_fr_max_range,
3880 v_min_range|| ' - '||v_max_range) and
3881 segment4 = v_employment_category and
3882 segment21 = v_naic_code;
3883
3884 elsif v_sex = 'F' then
3885
3886 update per_ca_ee_report_lines set
3887 segment5=segment5 + nvl(v_count,0),
3888 segment6=nvl(v_count,0)
3889 where
3890 request_id=p_request_id and
3891 line_number=per_ca_ee_extract_pkg.k and
3892 context='FORM3' and
3893 segment1=decode(i,1,'PROVINCE',2,'CMA') and
3894 segment2=v_meaning and
3895 segment3=decode(v_employment_category,'FR',
3896 v_fr_min_range|| ' - '||v_fr_max_range ,
3897 v_min_range|| ' - '||v_max_range) and
3898 segment4=v_employment_category and
3899 segment21 = v_naic_code;
3900
3901 end if;
3902 end if;
3903 end if;
3904
3905 prev_employment_category := v_employment_category;
3906 prev_sex := v_sex;
3907 prev_x := x;
3908 prev_meaning := v_meaning;
3909 prev_naic_code := v_naic_code;
3910
3911 end loop;
3912
3913
3914 ---------------------------------
3915 -- Updation designated Group --
3916 ---------------------------------
3917
3918 hr_utility.trace('Form3: v_fr_min_range: ' || to_char(v_fr_min_range));
3919 hr_utility.trace('Form3: v_fr_max_range: ' || to_char(v_fr_max_range));
3920
3921 for k in 1..3 loop
3922
3923 for l in cur_count(i,x,k) loop
3924
3925 hr_utility.trace('Form3: Updation Designated Group');
3926
3927 v_cma_province := l.cma_province;
3928 v_employment_category := l.employment_category;
3929
3930 hr_utility.trace('Form3: v_meaning: ' || v_meaning);
3931 hr_utility.trace('Form3: v_cma_province: ' || v_cma_province);
3932 hr_utility.trace('Form3: v_employment_category: '
3933 || v_employment_category);
3934 hr_utility.trace('Form3: v_fr_min_range: ' || to_char(v_fr_min_range));
3935 hr_utility.trace('Form3: v_fr_max_range: ' || to_char(v_fr_max_range));
3936
3937 open cur_meaning(i);
3938 fetch cur_meaning into v_meaning;
3939 close cur_meaning;
3940
3941 if k = 1 then
3942
3943 hr_utility.trace('Form3: Updation Designated Grp: k = 1. ');
3944 if l.sex = 'F' then
3945
3946 update per_ca_ee_report_lines set
3947 segment8=nvl(segment8,0) + nvl(l.count,0),
3948 segment9=nvl(l.count,0)
3949 where
3950 request_id = p_request_id and
3951 context = 'FORM3' and
3952 ltrim(rtrim(segment1)) = decode(i,1,'PROVINCE',2,'CMA') and
3953 ltrim(rtrim(segment2)) = v_meaning and
3954 ltrim(rtrim(segment3)) = decode(v_employment_category,'FR',
3955 v_fr_min_range|| ' - '||v_fr_max_range,
3956 v_min_range|| ' - ' ||v_max_range) and
3957 upper(ltrim(rtrim(segment4))) =
3958 upper(ltrim(rtrim(v_employment_category))) and
3959 segment21 = v_naic_code;
3960
3961 elsif l.sex = 'M' then
3962
3963 update per_ca_ee_report_lines set
3964 segment8 = nvl(segment8,0) + nvl(l.count,0),
3965 segment10 = nvl(l.count,0)
3966 where
3967 request_id = p_request_id and
3968 context = 'FORM3' and
3969 ltrim(rtrim(segment1)) = decode(i,1,'PROVINCE',2,'CMA') and
3970 ltrim(rtrim(segment2)) = v_meaning and
3971 rtrim(ltrim(segment3)) = decode(v_employment_category,'FR',
3972 v_fr_min_range|| ' - '||v_fr_max_range,
3976 segment21 = v_naic_code;
3973 v_min_range|| ' - ' ||v_max_range) and
3974 upper(ltrim(rtrim(segment4)))
3975 = upper(ltrim(rtrim(v_employment_category))) and
3977
3978 end if;
3979
3980 elsif k = 2 then
3981
3982 hr_utility.trace('Form3: Updation Designated Grp: k = 2. ');
3983
3984 if l.sex = 'F' then
3985
3986 update per_ca_ee_report_lines set
3987 segment11=nvl(segment11,0) + nvl(l.count,0),
3988 segment12=nvl(l.count,0)
3989 where
3990 request_id=p_request_id and
3991 context='FORM3' and
3992 ltrim(rtrim(segment1))=decode(i,1,'PROVINCE',2,'CMA') and
3993 ltrim(rtrim(segment2))=v_meaning and
3994 ltrim(rtrim(segment3))=decode(v_employment_category,'FR',
3995 v_fr_min_range|| ' - '||v_fr_max_range,
3996 v_min_range|| ' - ' ||v_max_range) and
3997 upper(ltrim(rtrim(segment4)))
3998 = upper(ltrim(rtrim(v_employment_category))) and
3999 segment21 = v_naic_code;
4000
4001 else
4002
4003 update per_ca_ee_report_lines set
4004 segment11=nvl(segment11,0) + nvl(l.count,0),
4005 segment13=nvl(l.count,0)
4006 where
4007 request_id=p_request_id and
4008 context='FORM3' and
4009 ltrim(rtrim(segment1))=decode(i,1,'PROVINCE',2,'CMA') and
4010 ltrim(rtrim(segment2))=v_meaning and
4011 ltrim(rtrim(segment3))= decode(v_employment_category,'FR',
4012 v_fr_min_range|| ' - '||v_fr_max_range,
4013 v_min_range|| ' - ' ||v_max_range) and
4014 upper(ltrim(rtrim(segment4)))
4015 = upper(ltrim(rtrim(v_employment_category))) and
4016 segment21 = v_naic_code;
4017
4018 end if;
4019
4020 elsif k = 3 then
4021
4022 hr_utility.trace('Form3: Updation Designated Grp: k = 3. ');
4023
4024 if l.sex = 'F' then
4025
4026 hr_utility.trace('Form3: Updation Designated Grp: k = 3. F ');
4027
4028 update per_ca_ee_report_lines set
4029 segment14=nvl(segment14,0) + nvl(l.count,0),
4030 segment16=nvl(l.count,0)
4031 where
4032 request_id=p_request_id and
4033 context='FORM3' and
4034 ltrim(rtrim(segment1))=decode(i,1,'PROVINCE',2,'CMA') and
4035 ltrim(rtrim(segment2))=v_meaning and
4036 ltrim(rtrim(segment3))= decode(v_employment_category,'FR',
4037 v_fr_min_range|| ' - '||v_fr_max_range,
4038 v_min_range|| ' - ' ||v_max_range) and
4039 upper(ltrim(rtrim(segment4)))
4040 =upper(ltrim(rtrim(v_employment_category))) and
4041 segment21 = v_naic_code;
4042
4043 else
4044
4045 hr_utility.trace('Form3: Updation Designated Grp: k = 3. M ');
4046 --hr_utility.trace('Form3: v_meaning: ' || v_meaning);
4047 --hr_utility.trace('Form3: v_cma_province: ' || v_cma_province);
4048 --hr_utility.trace('Form3: v_employment_category: '
4049 -- || v_employment_category);
4050 --hr_utility.trace('Form3: v_fr_min_range: ' || to_char(v_fr_min_range));
4051 --hr_utility.trace('Form3: v_fr_max_range: ' || to_char(v_fr_max_range));
4052
4053 update per_ca_ee_report_lines set
4054 segment14=nvl(segment14,0) + nvl(l.count,0),
4055 segment15=nvl(l.count,0)
4056 where
4057 request_id=p_request_id and
4058 context='FORM3' and
4059 ltrim(rtrim(segment1)) = decode(i,1,'PROVINCE',2,'CMA') and
4060 ltrim(rtrim(segment2)) = v_meaning and
4061 ltrim(rtrim(segment3)) = decode(v_employment_category,'FR',
4062 v_fr_min_range|| ' - '||v_fr_max_range,
4063 v_min_range|| ' - ' ||v_max_range) and
4064 upper(ltrim(rtrim(segment4)))
4065 =upper(ltrim(rtrim(v_employment_category))) and
4066 segment21 = v_naic_code;
4067 end if;
4068
4069 end if;
4070 end loop;
4071 end loop;
4072
4073 end loop;
4074 end loop;
4075
4076
4077 for x in 1..14 loop
4078
4079 if x = 1 then
4080
4081 v_min_range := 0;
4082 v_max_range := 4999;
4083
4084 v_fr_min_range := 0;
4085 v_fr_max_range := 14999;
4086
4087 elsif x = 2 then
4088
4089 v_min_range := 5000;
4090 v_max_range := 7499;
4091
4092 v_fr_min_range := 15000;
4093 v_fr_max_range := 19999;
4094
4095 elsif x = 3 then
4096
4097 v_min_range := 7500;
4098 v_max_range := 9999;
4099
4100 v_fr_min_range := 20000;
4101 v_fr_max_range := 24999;
4102
4103 elsif x = 4 then
4104
4105 v_min_range := 10000;
4106 v_max_range := 12499;
4107
4108 v_fr_min_range := 25000;
4109 v_fr_max_range := 29999;
4110
4111 elsif x = 5 then
4112
4113 v_min_range := 12500;
4114 v_max_range := 14999;
4115
4116 v_fr_min_range := 30000;
4117 v_fr_max_range := 34999;
4118
4119 elsif x = 6 then
4120
4121 v_min_range := 15000;
4122 v_max_range := 17499;
4123
4124 v_fr_min_range := 35000;
4128
4125 v_fr_max_range := 37499;
4126
4127 elsif x = 7 then
4129 v_min_range := 17500;
4130 v_max_range := 19999;
4131
4132 v_fr_min_range := 37500;
4133 v_fr_max_range := 39999;
4134
4135 elsif x = 8 then
4136
4137 v_min_range := 20000;
4138 v_max_range := 22499;
4139
4140 v_fr_min_range := 40000;
4141 v_fr_max_range := 44999;
4142
4143 elsif x = 9 then
4144
4145 v_min_range := 22500;
4146 v_max_range := 24999;
4147
4148 v_fr_min_range := 45000;
4149 v_fr_max_range := 49999;
4150
4151 elsif x = 10 then
4152
4153 v_min_range := 25000;
4154 v_max_range := 29999;
4155
4156 v_fr_min_range := 50000;
4157 v_fr_max_range := 59999;
4158
4159 elsif x = 11 then
4160
4161 v_min_range := 30000;
4162 v_max_range := 34499;
4163
4164 v_fr_min_range := 60000;
4165 v_fr_max_range := 69999;
4166
4167 elsif x = 12 then
4168
4169 v_min_range := 35000;
4170 v_max_range := 39999;
4171
4172 v_fr_min_range := 70000;
4173 v_fr_max_range := 84999;
4174
4175 elsif x = 13 then
4176
4177 v_min_range := 40000;
4178 v_max_range := 49999;
4179
4180 v_fr_min_range := 85000;
4181 v_fr_max_range := 99999;
4182
4183 elsif x = 14 then
4184
4185 v_min_range := 50000;
4186 v_max_range := 9999999;
4187
4188 v_fr_min_range := 100000;
4189 v_fr_max_range := 9999999;
4190
4191 end if;
4192
4193 for l_pc_count in 1..2 loop
4194
4195 if l_pc_count = 1 then
4196 pc_count := 1;
4197 else
4198 pc_count := 2;
4199 end if;
4200
4201 for l_emp_cat in 1..3 loop
4202
4203 if l_emp_cat = 1 then
4204 emp_cat := 'FR';
4205 elsif l_emp_cat = 2 then
4206 emp_cat := 'PR';
4207 elsif l_emp_cat = 3 then
4208 emp_cat := 'PT';
4209 end if;
4210
4211 for l in cur_notfound(x,
4212 pc_count,
4213 emp_cat)
4214 loop
4215
4216 per_ca_ee_extract_pkg.k := per_ca_ee_extract_pkg.k + 1;
4217
4218 insert into per_ca_ee_report_lines
4219 ( request_id,
4220 line_number,
4221 context,
4222 segment1,
4223 segment2,
4224 segment3,
4225 segment4,
4226 segment5,
4227 segment6,
4228 segment7,
4229 segment8,
4230 segment9,
4231 segment10,
4232 segment11,
4233 segment12,
4234 segment13,
4235 segment14,
4236 segment15,
4237 segment16,
4238 segment21) values
4239 ( p_request_id,
4240 per_ca_ee_extract_pkg.k,
4241 'FORM3',
4242 decode(pc_count,1,'PROVINCE','CMA'),
4243 l.provcma_name,
4244 decode(emp_cat,'FR',v_fr_min_range||' - '||v_fr_max_range,
4245 v_min_range||' - '||v_max_range),
4246 emp_cat,
4247 '0',
4248 '0',
4249 '0',
4250 '0',
4251 '0',
4252 '0',
4253 '0',
4254 '0',
4255 '0',
4256 '0',
4257 '0',
4258 '0',
4259 v_naic_code);
4260
4261 end loop;
4262
4263 end loop; --End loop emp_cat.
4264
4265 end loop; -- End loop pc_count
4266 end loop;
4267
4268 for count_national in cur_count_national loop
4269
4270 hr_utility.trace('Form3: cur_count_national. ');
4271
4272 insert into per_ca_ee_report_lines
4273 (request_id,
4274 line_number,
4275 context,
4276 segment1,
4277 segment2,
4278 segment3,
4279 segment4,
4280 segment5,
4281 segment6,
4282 segment7,
4283 segment8,
4284 segment9,
4285 segment10,
4286 segment11,
4287 segment12,
4288 segment13,
4289 segment14,
4290 segment15,
4291 segment21) values
4292 ( p_request_id,
4293 per_ca_ee_extract_pkg.k,
4294 'FORM3',
4295 'NATIONAL',
4296 count_national.segment3,
4297 count_national.segment4,
4298 count_national.segment5,
4299 count_national.segment6,
4300 count_national.segment7,
4301 count_national.segment8,
4302 count_national.segment9,
4303 count_national.segment10,
4304 count_national.segment11,
4305 count_national.segment12,
4306 count_national.segment13,
4307 count_national.segment14,
4308 count_national.segment15,
4309 count_national.segment16,
4310 v_naic_code);
4311
4312 end loop; --End of loop cur_national_count
4313
4314 prev_naic_code := v_naic_code;
4315
4316 end loop; -- End loop for cur_naic
4317
4318
4319 return 1;
4320 end;
4321
4322 end form3;
4323
4324 function form4(p_business_group_id in number,
4325 p_request_id in number,
4326 p_year in varchar2,
4327 p_date_tmp_emp in date) return number is
4328
4329 l_year_start date;
4330 l_year_end date;
4331
4332 begin
4333
4334 l_year_start := trunc(to_date(p_year,'YYYY'),'Y');
4335 l_year_end := add_months(trunc(to_date(p_year,'YYYY'),'Y'), 12) -1;
4336
4337 declare
4338
4339 cursor cur_naic is
4340 select
4341 pert.segment4 naic_code
4342 from
4343 per_ca_ee_report_lines pert
4344 where
4345 pert.request_id = p_request_id and
4346 pert.context = 'FORM12';
4347
4348 v_naic_code hr_lookups.lookup_code%TYPE;
4349
4350 cursor cur_hired_total is
4351 select
4352 count(distinct count_total) count_total,
4353 meaning meaning,
4354 sex sex,
4355 employment_category employment_category,
4356 province province
4357 from
4358 (
4359 select
4360 paf.person_id count_total,
4361 hl.meaning meaning,
4362 ppf.sex sex,
4363 substr(employment_category,1,2) employment_category,
4364 hl1.region_1 province
4365 from
4366 hr_lookups hl,
4367 per_jobs pj,
4368 per_assignments_f paf,
4369 per_people_f ppf,
4370 per_person_types ppt,
4371 hr_locations hl1,
4372 per_ca_ee_report_lines pert,
4373 hr_lookups hl2,
4374 hr_soft_coding_keyflex hsck
4375 where
4376 hl.lookup_type='EEOG' and
4377 upper(ltrim(rtrim(hl.lookup_code)))
4378 = upper(ltrim(rtrim(pj.job_information1))) and
4379 upper(ltrim(rtrim(pj.job_information_category))) = 'CA' and
4380 pj.job_id=paf.job_id and
4381 paf.primary_flag = 'Y' and
4382 --decode(paf.employment_category,'PT',p_date_tmp_emp,l_year_end) between
4383 -- paf.effective_start_date and
4384 -- paf.effective_end_date and
4385 --paf.effective_start_date < l_year_end and
4386 --paf.effective_end_date > l_year_start and
4387 ppf.start_date between
4388 paf.effective_start_date and
4389 paf.effective_end_date and
4390 paf.employment_category is not null and
4391 substr(employment_category,1,2) in ('FR','PR','PT') and
4392 paf.person_id=ppf.person_id and
4393 --decode(paf.employment_category,'PT',p_date_tmp_emp,l_year_end) between
4394 -- ppf.effective_start_date and
4395 -- ppf.effective_end_date and
4396 ppf.effective_start_date < l_year_end and
4397 ppf.effective_end_date > l_year_start and
4398 ppf.start_date between l_year_start and
4399 l_year_end and
4400 ppf.person_type_id=ppt.person_type_id and
4401 upper(ltrim(rtrim(ppt.system_person_type)))='EMP' and
4402 ppf.business_group_id=p_business_group_id and
4403 paf.location_id=hl1.location_id and
4404 hl1.region_1=hl2.lookup_code and
4405 hl2.lookup_type='CA_PROVINCE' and
4406 pert.request_id=p_request_id and
4407 hl2.meaning=pert.segment2 and
4408 --pert.segment4 = 'Y' and
4409 pert.context='FORM14' and
4410 pert.segment1='PROVINCE' and
4411 (
4412 (
4413 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
4414 hsck.segment6 is not null and
4415 hsck.segment6 = v_naic_code
4416 )
4417 OR
4418 (
4419 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
4420 hsck.segment6 is null and
4421 hsck.segment1 in (select segment3
4422 from per_ca_ee_report_lines
4423 where request_id = p_request_id and
4424 context = 'FORM13' and
4425 segment1 = 'NAIC' and
4426 segment2 = v_naic_code)
4427 )
4428 ) and
4429 exists
4430 (
4431 select 'X'
4432 from per_pay_proposals_v2 pppv
4433 where
4434 pppv.assignment_id = paf.assignment_id and
4435 pppv.approved = 'Y' and
4436 pppv.change_date <= l_year_end
4437 )
4438 union all
4439 select
4440 paf.person_id count_total,
4441 hl.meaning meaning,
4442 ppf.sex sex,
4443 'FR' employment_category,
4444 hl1.region_1 province
4445 from
4446 hr_lookups hl,
4447 per_jobs pj,
4448 per_assignments_f paf,
4449 per_people_f ppf,
4450 per_person_types ppt,
4451 hr_locations hl1,
4452 per_ca_ee_report_lines pert,
4453 hr_lookups hl2,
4454 hr_soft_coding_keyflex hsck
4455 where
4456 hl.lookup_type='EEOG' and
4457 upper(ltrim(rtrim(hl.lookup_code)))
4458 =upper(ltrim(rtrim(pj.job_information1))) and
4459 upper(ltrim(rtrim(pj.job_information_category))) = 'CA' and
4460 pj.job_id=paf.job_id and
4461 paf.primary_flag = 'Y' and
4462 --l_year_end between
4463 -- paf.effective_start_date and
4464 -- paf.effective_end_date and
4465 --paf.effective_start_date < l_year_end and
4466 --paf.effective_end_date > l_year_start and
4467 ppf.start_date between
4468 paf.effective_start_date and
4469 paf.effective_end_date and
4470 (paf.employment_category is null OR
4471 substr(paf.employment_category,1,2) not in ('FR','PR','PT')) and
4472 paf.person_id=ppf.person_id and
4473 --l_year_end between
4474 -- ppf.effective_start_date and
4475 -- ppf.effective_end_date and
4476 ppf.effective_start_date < l_year_end and
4477 ppf.effective_end_date > l_year_start and
4478 ppf.start_date between l_year_start and
4479 l_year_end and
4480 ppf.person_type_id=ppt.person_type_id and
4481 upper(ltrim(rtrim(ppt.system_person_type)))='EMP' and
4482 ppf.business_group_id=p_business_group_id and
4483 paf.location_id=hl1.location_id and
4484 hl1.region_1=hl2.lookup_code and
4485 hl2.lookup_type='CA_PROVINCE' and
4486 pert.request_id=p_request_id and
4487 hl2.meaning=pert.segment2 and
4488 --pert.segment4 = 'Y' and
4489 pert.context='FORM14' and
4490 pert.segment1='PROVINCE' and
4491 (
4492 (
4493 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
4494 hsck.segment6 is not null and
4495 hsck.segment6 = v_naic_code
4496 )
4497 OR
4498 (
4499 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
4500 hsck.segment6 is null and
4501 hsck.segment1 in (select segment3
4502 from per_ca_ee_report_lines
4503 where request_id = p_request_id and
4504 context = 'FORM13' and
4505 segment1 = 'NAIC' and
4506 segment2 = v_naic_code)
4507 )
4508 ) and
4509 exists
4510 (
4511 select 'X'
4512 from per_pay_proposals_v2 pppv
4513 where
4514 pppv.assignment_id = paf.assignment_id and
4515 pppv.approved = 'Y' and
4516 pppv.change_date <= l_year_end
4517 ) -- End of Exists
4518 )
4519 group by province,meaning,employment_category,sex
4520 order by province,meaning,employment_category,sex;
4521
4522 v_count number(10);
4523 v_meaning hr_lookups.meaning%TYPE;
4524 v_employment_category per_assignments_f.employment_category%TYPE;
4525 v_sex per_people_f.sex%TYPE;
4526 v_province hr_locations.region_1%TYPE;
4527 prev_meaning hr_lookups.meaning%TYPE := 'test';
4528 prev_employment_category per_assignments_f.employment_category%TYPE := 'test';
4529 prev_sex per_people_f.sex%TYPE := 'test';
4530 prev_naic_code hr_lookups.lookup_code%TYPE;
4531
4532 cursor cur_meaning is
4533 select
4534 meaning
4535 from
4536 hr_lookups
4537 where
4538 upper(ltrim(rtrim(lookup_type)))='CA_PROVINCE' and
4539 upper(ltrim(rtrim(lookup_code)))=upper(ltrim(rtrim(v_province)));
4540
4541 v_province_name hr_lookups.meaning%TYPE;
4542 prev_province_name hr_lookups.meaning%TYPE;
4543
4544 cursor cur_hired(desig NUMBER) is
4545 select
4546 count(distinct person_id) count,
4547 meaning meaning,
4548 employment_category employment_category,
4549 sex sex,
4550 province province
4551 from
4552 (
4553 select
4554 paf.person_id person_id,
4555 hl.meaning meaning,
4556 substr(paf.employment_category,1,2) employment_category,
4557 ppf.sex sex,
4558 hl1.region_1 province
4559 from
4560 hr_lookups hl,
4561 per_jobs pj,
4562 per_assignments_f paf,
4563 per_people_f ppf,
4564 per_person_types ppt,
4565 hr_locations hl1,
4566 per_ca_ee_report_lines pert,
4567 hr_lookups hl2,
4568 hr_soft_coding_keyflex hsck
4569 where
4570 upper(ltrim(rtrim(hl.lookup_type)))='EEOG' and
4571 upper(ltrim(rtrim(hl.lookup_code)))=
4572 upper(ltrim(ltrim(pj.job_information1))) and
4573 upper(ltrim(rtrim(pj.job_information_category))) = 'CA' and
4574 pj.job_id=paf.job_id and
4575 paf.primary_flag = 'Y' and
4576 --decode(paf.employment_category,'PT',p_date_tmp_emp,l_year_end) between
4577 -- paf.effective_start_date and
4578 -- paf.effective_end_date and
4579 --paf.effective_start_date < l_year_end and
4580 --paf.effective_end_date > l_year_start and
4581 ppf.start_date between
4582 paf.effective_start_date and
4583 paf.effective_end_date and
4584 paf.employment_category is not null and
4585 substr(paf.employment_category,1,2) in ('FR','PR','PT') and
4586 paf.person_id=ppf.person_id and
4587 --decode(paf.employment_category,'PT',p_date_tmp_emp,l_year_end) between
4588 -- ppf.effective_start_date and
4589 -- ppf.effective_end_date and
4590 ppf.effective_start_date < l_year_end and
4591 ppf.effective_end_date > l_year_start and
4592 ppf.start_date between l_year_start and
4593 l_year_end and
4594 ppf.person_type_id=ppt.person_type_id and
4595 upper(ltrim(rtrim(ppt.system_person_type)))='EMP' and
4596 ppf.business_group_id=p_business_group_id and
4597 paf.location_id=hl1.location_id and
4598 hl1.region_1=hl2.lookup_code and
4599 hl2.lookup_type='CA_PROVINCE' and
4600 pert.request_id=p_request_id and
4601 hl2.meaning=pert.segment2 and
4602 --pert.segment4 = 'Y' and
4603 pert.context='FORM14' and
4604 pert.segment1='PROVINCE' and
4605 decode(desig,1,ppf.per_information5,
4606 2,ppf.per_information6,
4607 3,ppf.per_information7)='Y' and
4608 /* Modified the condition for Bug 11651960
4609 (
4610 (
4611 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
4612 hsck.segment6 is not null and
4613 hsck.segment6 = v_naic_code
4614 )
4615 OR
4616 (
4617 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
4618 hsck.segment6 is null and
4619 hsck.segment1 in (select segment3
4620 from per_ca_ee_report_lines
4621 where request_id = p_request_id and
4622 context = 'FORM13' and
4623 segment1 = 'NAIC' and
4624 segment2 = v_naic_code)
4625 )
4626 ) and */
4627 ( hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
4628 ((
4629 hsck.segment6 is not null and
4630 hsck.segment6 = v_naic_code
4631 )
4632 OR
4633 (
4634 hsck.segment6 is null and
4635 hsck.segment1 in (select segment3
4636 from per_ca_ee_report_lines
4637 where request_id = p_request_id and
4638 context = 'FORM13' and
4639 segment1 = 'NAIC' and
4640 segment2 = v_naic_code)
4641 ))
4642 ) and
4643 exists
4644 (
4645 select 'X'
4646 from per_pay_proposals_v2 pppv
4647 where
4648 pppv.assignment_id = paf.assignment_id and
4649 pppv.approved = 'Y' and
4653 select
4650 pppv.change_date <= l_year_end
4651 ) -- End of Exists
4652 union all
4654 paf.person_id person_id,
4655 hl.meaning meaning,
4656 'FR' employment_category,
4657 ppf.sex sex,
4658 hl1.region_1 province
4659 from
4660 hr_lookups hl,
4661 per_jobs pj,
4662 per_assignments_f paf,
4663 per_people_f ppf,
4664 per_person_types ppt,
4665 hr_locations hl1,
4666 per_ca_ee_report_lines pert,
4667 hr_lookups hl2,
4668 hr_soft_coding_keyflex hsck
4669 where
4670 upper(ltrim(rtrim(hl.lookup_type)))='EEOG' and
4671 upper(ltrim(rtrim(hl.lookup_code)))
4672 = upper(ltrim(ltrim(pj.job_information1))) and
4673 upper(ltrim(rtrim(pj.job_information_category))) = 'CA' and
4674 pj.job_id=paf.job_id and
4675 paf.primary_flag = 'Y' and
4676 --l_year_end between
4677 -- paf.effective_start_date and
4678 -- paf.effective_end_date and
4679 -- paf.effective_start_date < l_year_end and
4680 -- paf.effective_end_date > l_year_start and
4681 ppf.start_date between
4682 paf.effective_start_date and
4683 paf.effective_end_date and
4684 (paf.employment_category is null OR
4685 substr(paf.employment_category,1,2) not in ('FR','PR','PT')) and
4686 paf.person_id=ppf.person_id and
4687 --l_year_end between
4688 -- ppf.effective_start_date and
4689 -- ppf.effective_end_date and
4690 ppf.effective_start_date < l_year_end and
4691 ppf.effective_end_date > l_year_start and
4692 ppf.start_date between l_year_start and
4693 l_year_end and
4694 ppf.person_type_id=ppt.person_type_id and
4695 upper(ltrim(rtrim(ppt.system_person_type)))='EMP' and
4696 ppf.business_group_id=p_business_group_id and
4697 paf.location_id=hl1.location_id and
4698 hl1.region_1=hl2.lookup_code and
4699 hl2.lookup_type='CA_PROVINCE' and
4700 pert.request_id=p_request_id and
4701 hl2.meaning=pert.segment2 and
4702 --pert.segment4 = 'Y' and
4703 pert.context='FORM14' and
4704 pert.segment1='PROVINCE' and
4705 decode(desig,1,ppf.per_information5,
4706 2,ppf.per_information6,
4707 3,ppf.per_information7)='Y' and
4708 /* Modified the condition for Bug 11651960
4709 (
4710 (
4711 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
4712 hsck.segment6 is not null and
4713 hsck.segment6 = v_naic_code
4714 )
4715 OR
4716 (
4717 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
4718 hsck.segment6 is null and
4719 hsck.segment1 in (select segment3
4720 from per_ca_ee_report_lines
4721 where request_id = p_request_id and
4722 context = 'FORM13' and
4723 segment1 = 'NAIC' and
4724 segment2 = v_naic_code)
4725 )
4726 ) and */
4727 ( hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
4728 ((
4729 hsck.segment6 is not null and
4730 hsck.segment6 = v_naic_code
4731 )
4732 OR
4733 (
4734 hsck.segment6 is null and
4735 hsck.segment1 in (select segment3
4736 from per_ca_ee_report_lines
4737 where request_id = p_request_id and
4738 context = 'FORM13' and
4739 segment1 = 'NAIC' and
4740 segment2 = v_naic_code)
4741 ))
4742 ) and
4743 exists
4744 (
4745 select 'X'
4746 from per_pay_proposals_v2 pppv
4747 where
4748 pppv.assignment_id = paf.assignment_id and
4749 pppv.approved = 'Y' and
4750 pppv.change_date <= l_year_end
4751 ) -- End of Exists
4752 )
4753 group by province,meaning,employment_category,sex
4754 order by province,meaning,employment_category,sex;
4755
4756 cursor cur_eeog is
4757 select
4758 meaning
4759 from
4760 hr_lookups
4761 where
4762 lookup_type='EEOG';
4763
4764 cursor cur_notfound(p_emp_cat number) is
4765 select
4766 segment2,
4767 v_meaning,
4768 decode(p_emp_cat,1,'FR',2,'PR',3,'PT') emp_category
4769 from
4770 per_ca_ee_report_lines where
4771 request_id=p_request_id and
4772 context='FORM14' and
4773 segment1='PROVINCE' and
4774 segment3 <> '0'
4775 minus
4776 select
4777 segment2,
4778 segment3,
4779 segment4
4780 from
4781 per_ca_ee_report_lines
4782 where
4783 request_id=p_request_id and
4784 context='FORM4' and
4785 segment1='PROVINCE'and
4786 segment21 = v_naic_code;
4787
4788 cursor cur_count_national is
4789 select
4790 segment3,
4791 segment4,
4792 sum(to_number(segment5)) segment5,
4793 sum(to_number(segment6)) segment6,
4794 sum(to_number(segment7)) segment7,
4795 sum(to_number(segment8)) segment8,
4796 sum(to_number(segment9)) segment9,
4797 sum(to_number(segment10)) segment10,
4798 sum(to_number(segment11)) segment11,
4799 sum(to_number(segment12)) segment12,
4800 sum(to_number(segment13)) segment13,
4801 sum(to_number(segment14)) segment14,
4802 sum(to_number(segment15)) segment15,
4803 sum(to_number(segment16)) segment16
4804 from
4805 per_ca_ee_report_lines
4806 where
4810 segment21 = v_naic_code
4807 request_id = p_request_id and
4808 context = 'FORM4' and
4809 segment1 = 'PROVINCE' and
4811 group by segment3,segment4;
4812
4813 begin
4814
4815 hr_utility.trace('Form4 starts Here !!!!!!');
4816
4817 for naic in cur_naic loop
4818
4819 v_naic_code := naic.naic_code;
4820
4821 hr_utility.trace('Form4: v_naic = ' || v_naic_code );
4822
4823 for j in cur_hired_total
4824 loop
4825
4826 v_count := j.count_total;
4827 v_meaning := j.meaning;
4828 v_employment_category := j.employment_category;
4829 v_sex := j.sex;
4830 v_province := j.province;
4831
4832 hr_utility.trace('Form4: v_meaning = ' || v_meaning );
4833
4834 open cur_meaning;
4835 fetch cur_meaning into v_province_name;
4836 close cur_meaning;
4837
4838 if ((ltrim(rtrim(v_province_name))<>ltrim(rtrim(prev_province_name))) or
4839 (ltrim(rtrim(prev_meaning)) <> ltrim(rtrim(v_meaning))) or
4840 (ltrim(rtrim(prev_naic_code)) <> ltrim(rtrim(v_naic_code))) or
4841 (ltrim(rtrim(prev_employment_category)) <> ltrim(rtrim(v_employment_category)))) then
4842
4843 per_ca_ee_extract_pkg.k := per_ca_ee_extract_pkg.k + 1;
4844
4845 insert into per_ca_ee_report_lines
4846 (request_id,
4847 line_number,
4848 context,
4849 segment1,
4850 segment2,
4851 segment3,
4852 segment4,
4853 segment5,
4854 segment6,
4855 segment7,
4856 segment8,
4857 segment9,
4858 segment10,
4859 segment11,
4860 segment12,
4861 segment13,
4862 segment14,
4863 segment15,
4864 segment16,
4865 segment21) values
4866 ( p_request_id,
4867 per_ca_ee_extract_pkg.k,
4868 'FORM4',
4869 'PROVINCE',
4870 v_province_name,
4871 v_meaning,
4872 v_employment_category,
4873 nvl(v_count,0),
4874 decode(v_sex,'F',v_count,0),
4875 decode(v_sex,'M',v_count,0),
4876 '0',
4877 '0',
4878 '0',
4879 '0',
4880 '0',
4881 '0',
4882 '0',
4883 '0',
4884 '0',
4885 v_naic_code);
4886
4887 else
4888
4889 if prev_province_name = v_province_name and
4890 prev_meaning = v_meaning and
4891 prev_naic_code = v_naic_code and
4892 prev_employment_category = v_employment_category and
4893 prev_sex <> v_sex then
4894
4895 if v_sex = 'M' then
4896
4897 update per_ca_ee_report_lines set
4898 segment7=nvl(v_count,0),
4899 segment5=segment5 + nvl(v_count,0)
4900 where request_id=p_request_id and
4901 line_number=per_ca_ee_extract_pkg.k and
4902 context='FORM4' and
4903 segment1='PROVINCE' and
4904 segment2=v_province_name and
4905 segment3=v_meaning and
4906 segment4=v_employment_category and
4907 segment21 = v_naic_code;
4908
4909 elsif v_sex = 'F' then
4910
4911 update per_ca_ee_report_lines set
4912 segment6=nvl(v_count,0),
4913 segment5=segment5 + nvl(v_count,0)
4914 where request_id=p_request_id and
4915 line_number=per_ca_ee_extract_pkg.k and
4916 context='FORM4' and
4917 segment1='PROVINCE' and
4918 segment2=v_province_name and
4919 segment3=v_meaning and
4920 segment4=v_employment_category and
4921 segment21 = v_naic_code;
4922
4923 end if;
4924
4925 end if;
4926 end if;
4927
4928 prev_meaning := v_meaning;
4929 prev_employment_category := v_employment_category;
4930 prev_sex := v_sex;
4931 prev_province_name := v_province_name;
4932 prev_naic_code := v_naic_code;
4933
4934 end loop; -- End loop cur_hired_total
4935
4936 for i in 1..3 loop
4937
4938 for j in cur_hired(i)
4939 loop
4940
4941 v_sex := j.sex;
4942 v_employment_category := j.employment_category;
4943 v_meaning := j.meaning;
4944 v_count := j.count;
4945 v_province := j.province;
4946
4947 open cur_meaning;
4948 fetch cur_meaning into v_province_name;
4949 close cur_meaning;
4950
4951 if i = 1 then
4952 if v_sex = 'M' then
4953 update per_ca_ee_report_lines set
4954 segment8 = nvl(segment8,0) + nvl(v_count,0),
4955 segment10 = nvl(v_count,0)
4956 where
4957 request_id = p_request_id and
4958 context='FORM4' and
4959 segment1 = 'PROVINCE' and
4960 segment2 = v_province_name and
4961 segment3 = v_meaning and
4965 segment8 = nvl(segment8,0) + nvl(v_count,0),
4962 segment4 = v_employment_category;
4963 elsif v_sex = 'F' then
4964 update per_ca_ee_report_lines set
4966 segment9 = nvl(v_count,0)
4967 where
4968 request_id = p_request_id and
4969 context='FORM4' and
4970 segment1 = 'PROVINCE' and
4971 segment2 = v_province_name and
4972 segment3 = v_meaning and
4973 segment4 = v_employment_category;
4974 end if;
4975 elsif i = 2 then
4976 if v_sex = 'M' then
4977 update per_ca_ee_report_lines set
4978 segment11 = nvl(segment11,0) + nvl(v_count,0),
4979 segment13 = nvl(v_count,0)
4980 where
4981 request_id = p_request_id and
4982 context='FORM4' and
4983 segment1 = 'PROVINCE' and
4984 segment2 = v_province_name and
4985 segment3 = v_meaning and
4986 segment4 = v_employment_category;
4987 elsif v_sex = 'F' then
4988 update per_ca_ee_report_lines set
4989 segment11 = nvl(segment11,0) + nvl(v_count,0),
4990 segment12 = nvl(v_count,0)
4991 where
4992 request_id = p_request_id and
4993 context='FORM4' and
4994 segment1 = 'PROVINCE' and
4995 segment2 = v_province_name and
4996 segment3 = v_meaning and
4997 segment4 = v_employment_category;
4998 end if;
4999 elsif i = 3 then
5000 if v_sex = 'M' then
5001 update per_ca_ee_report_lines set
5002 segment14 = nvl(segment14,0) + nvl(v_count,0),
5003 segment16 = nvl(v_count,0)
5004 where
5005 request_id = p_request_id and
5006 context='FORM4' and
5007 segment1 = 'PROVINCE' and
5008 segment2 = v_province_name and
5009 segment3 = v_meaning and
5010 segment4 = v_employment_category;
5011 elsif v_sex = 'F' then
5012 update per_ca_ee_report_lines set
5013 segment14 = nvl(segment14,0) + nvl(v_count,0),
5014 segment15 = nvl(v_count,0)
5015 where
5016 request_id = p_request_id and
5017 context='FORM4' and
5018 segment1 = 'PROVINCE' and
5019 segment2 = v_province_name and
5020 segment3 = v_meaning and
5021 segment4 = v_employment_category;
5022 end if;
5023 end if;
5024 end loop; -- End loop cur_hired
5025
5026 end loop; -- End loop for designated group
5027
5028 for i in cur_eeog loop
5029
5030 v_meaning := i.meaning;
5031
5032 hr_utility.trace('Form4: cur_eeog: v_eeog' || v_meaning);
5033
5034 for emp_cat in 1..3 loop
5035
5036 for x in cur_notfound(emp_cat) loop
5037
5038 per_ca_ee_extract_pkg.k := per_ca_ee_extract_pkg.k + 1;
5039
5040 insert into per_ca_ee_report_lines
5041 (request_id,
5042 line_number,
5043 context,
5044 segment1,
5045 segment2,
5046 segment3,
5047 segment4,
5048 segment5,
5049 segment6,
5050 segment7,
5051 segment8,
5052 segment9,
5053 segment10,
5054 segment11,
5055 segment12,
5056 segment13,
5057 segment14,
5058 segment15,
5059 segment16,
5060 segment21) values
5061 ( p_request_id,
5062 per_ca_ee_extract_pkg.k,
5063 'FORM4',
5064 'PROVINCE',
5065 x.segment2,
5066 v_meaning,
5067 x.emp_category,
5068 0,
5069 0,
5070 0,
5071 0,
5072 0,
5073 0,
5074 0,
5075 0,
5076 0,
5077 0,
5078 0,
5079 0,
5080 v_naic_code);
5081
5082 end loop;
5083
5084 end loop;
5085
5086 end loop;
5087
5088
5089 hr_utility.trace('Form4: End of loop cur_naic');
5090
5091 for count_national in cur_count_national loop
5092
5093 hr_utility.trace('Form4: cur_count_national. ');
5094
5095 insert into per_ca_ee_report_lines
5096 (request_id,
5097 line_number,
5098 context,
5099 segment1,
5103 segment5,
5100 segment2,
5101 segment3,
5102 segment4,
5104 segment6,
5105 segment7,
5106 segment8,
5107 segment9,
5108 segment10,
5109 segment11,
5110 segment12,
5111 segment13,
5112 segment14,
5113 segment15,
5114 segment21) values
5115 ( p_request_id,
5116 per_ca_ee_extract_pkg.k,
5117 'FORM4',
5118 'NATIONAL',
5119 count_national.segment3,
5120 count_national.segment4,
5121 count_national.segment5,
5122 count_national.segment6,
5123 count_national.segment7,
5124 count_national.segment8,
5125 count_national.segment9,
5126 count_national.segment10,
5127 count_national.segment11,
5128 count_national.segment12,
5129 count_national.segment13,
5130 count_national.segment14,
5131 count_national.segment15,
5132 count_national.segment16,
5133 v_naic_code);
5134
5135 end loop; -- End loop cur_count_total
5136
5137 prev_naic_code := v_naic_code;
5138
5139 end loop; -- End of loop cur_naic
5140
5141
5142 return 1;
5143
5144 end;
5145
5146 end form4;
5147 /*
5148 function form5(p_business_group_id in number,
5149 p_request_id in number,
5150 p_year in varchar2,
5151 p_date_tmp_emp in date) return number is
5152
5153 l_year_start date;
5154 l_year_end date;
5155
5156 begin
5157
5158 l_year_start := trunc(to_date(p_year,'YYYY'),'Y');
5159 l_year_end := add_months(trunc(to_date(p_year,'YYYY'),'Y'), 12) -1;
5160
5161 declare
5162
5163 cursor cur_naic is
5164 select
5165 pert.segment4 naic_code
5166 from
5167 per_ca_ee_report_lines pert
5168 where
5169 pert.request_id = p_request_id and
5170 pert.context = 'FORM12';
5171
5172 v_naic_code hr_lookups.lookup_code%TYPE;
5173
5174 cursor cur_promoted_total is
5175 select
5176 count(distinct count_total) count_total,
5177 meaning meaning,
5178 sex sex,
5179 employment_category employment_category,
5180 province province
5181 from
5182 (
5183 select
5184 paf.person_id count_total,
5185 hl.meaning meaning,
5186 ppf.sex sex,
5187 substr(paf.employment_category,1,2) employment_category,
5188 hl1.region_1 province
5189 from
5190 hr_lookups hl,
5191 per_jobs pj,
5192 per_assignments_f paf,
5193 per_people_f ppf,
5194 per_person_types ppt,
5195 hr_locations hl1,
5196 per_ca_ee_report_lines pert,
5197 hr_lookups hl2,
5198 hr_soft_coding_keyflex hsck
5199 where
5200 hl.lookup_type='EEOG' and
5201 upper(ltrim(rtrim(hl.lookup_code)))
5202 =upper(ltrim(rtrim(pj.job_information1))) and
5203 upper(ltrim(rtrim(pj.job_information_category))) = 'CA' and
5204 pj.job_id=paf.job_id and
5205 paf.primary_flag = 'Y' and
5206 --decode(paf.employment_category,'PT',p_date_tmp_emp,l_year_end) between
5207 -- paf.effective_start_date and
5208 -- paf.effective_end_date and
5209 ppf.start_date between
5210 paf.effective_start_date and
5211 paf.effective_end_date and
5212 paf.employment_category is not null and
5213 substr(paf.employment_category,1,2) in ('FR','PR','PT') and
5214 paf.person_id=ppf.person_id and
5215 --decode(paf.employment_category,'PT',p_date_tmp_emp,l_year_end) between
5216 -- ppf.effective_start_date and
5217 -- ppf.effective_end_date and
5218 ppf.effective_start_date < l_year_end and
5219 ppf.effective_end_date > l_year_start and
5220 ppf.person_type_id=ppt.person_type_id and
5221 upper(ltrim(rtrim(ppt.system_person_type)))='EMP' and
5222 ppf.business_group_id=p_business_group_id and
5223 paf.location_id=hl1.location_id and
5224 hl1.region_1=hl2.lookup_code and
5225 hl2.lookup_type='CA_PROVINCE' and
5226 pert.request_id=p_request_id and
5227 hl2.meaning=pert.segment2 and
5228 --pert.segment4 = 'Y' and
5229 pert.context='FORM14' and
5230 pert.segment1='PROVINCE' and
5231 (
5232 (
5233 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
5234 hsck.segment6 is not null and
5235 hsck.segment6 = v_naic_code
5236 )
5237 OR
5238 (
5239 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
5240 hsck.segment6 is null and
5241 hsck.segment1 in (select segment3
5242 from per_ca_ee_report_lines
5243 where request_id = p_request_id and
5244 context = 'FORM13' and
5245 segment1 = 'NAIC' and
5246 segment2 = v_naic_code)
5247 )
5248 ) and
5249 exists
5250 (
5251 select 'X'
5252 from per_pay_proposals_v2 pppv
5253 where
5254 pppv.assignment_id = paf.assignment_id and
5258 pppv.proposal_reason =
5255 pppv.approved = 'Y' and
5256 pppv.change_date between l_year_start and
5257 l_year_end and
5259 (
5260 select lookup_code
5261 from hr_lookups
5262 where lookup_type = 'PROPOSAL_REASON' and
5263 upper(meaning) = 'PROMOTION'
5264 )
5265 )
5266 union all
5267 select
5268 paf.person_id count_total,
5269 hl.meaning meaning,
5270 ppf.sex sex,
5271 'FR' employment_category,
5272 hl1.region_1 province
5273 from
5274 hr_lookups hl,
5275 per_jobs pj,
5276 per_assignments_f paf,
5277 per_people_f ppf,
5278 per_person_types ppt,
5279 hr_locations hl1,
5280 per_ca_ee_report_lines pert,
5281 hr_lookups hl2,
5282 hr_soft_coding_keyflex hsck
5283 where
5284 hl.lookup_type='EEOG' and
5285 upper(ltrim(rtrim(hl.lookup_code)))
5286 =upper(ltrim(rtrim(pj.job_information1))) and
5287 upper(ltrim(rtrim(pj.job_information_category))) = 'CA' and
5288 pj.job_id=paf.job_id and
5289 paf.primary_flag = 'Y' and
5290 --l_year_end between
5291 -- ppf.effective_start_date and
5292 -- ppf.effective_end_date and
5293 ppf.start_date between
5294 paf.effective_start_date and
5295 paf.effective_end_date and
5296 (paf.employment_category is null OR
5297 substr(paf.employment_category,1,2) not in ('FR','PR','PT')) and
5298 paf.person_id=ppf.person_id and
5299 ppf.effective_start_date < l_year_end and
5300 ppf.effective_end_date > l_year_start and
5301 --l_year_end between
5302 -- ppf.effective_start_date and
5303 -- ppf.effective_end_date and
5304 ppf.person_type_id=ppt.person_type_id and
5305 upper(ltrim(rtrim(ppt.system_person_type)))='EMP' and
5306 ppf.business_group_id=p_business_group_id and
5307 paf.location_id=hl1.location_id and
5308 hl1.region_1=hl2.lookup_code and
5309 hl2.lookup_type='CA_PROVINCE' and
5310 pert.request_id=p_request_id and
5311 hl2.meaning=pert.segment2 and
5312 --pert.segment4 = 'Y' and
5313 pert.context='FORM14' and
5314 pert.segment1='PROVINCE' and
5315 (
5316 (
5317 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
5318 hsck.segment6 is not null and
5319 hsck.segment6 = v_naic_code
5320 )
5321 OR
5322 (
5323 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
5324 hsck.segment6 is null and
5325 hsck.segment1 in (select segment3
5326 from per_ca_ee_report_lines
5327 where request_id = p_request_id and
5328 context = 'FORM13' and
5329 segment1 = 'NAIC' and
5330 segment2 = v_naic_code)
5331 )
5332 ) and
5333 exists
5334 (
5335 select 'X'
5336 from per_pay_proposals_v2 pppv
5337 where
5338 pppv.assignment_id = paf.assignment_id and
5339 pppv.approved = 'Y' and
5340 pppv.change_date between l_year_start and
5341 l_year_end and
5342 pppv.proposal_reason =
5343 (
5344 select lookup_code
5345 from hr_lookups
5346 where lookup_type = 'PROPOSAL_REASON' and
5347 upper(meaning) = 'PROMOTION'
5348 )
5349 )
5350 )
5351 group by province,meaning,employment_category,sex
5352 order by province,meaning,employment_category,sex;
5353
5354 v_count number(10);
5355 v_meaning hr_lookups.meaning%TYPE;
5356 v_employment_category per_assignments_f.employment_category%TYPE;
5357 v_sex per_people_f.sex%TYPE;
5358 v_province hr_locations.region_1%TYPE;
5359 prev_meaning hr_lookups.meaning%TYPE := 'test';
5360 prev_employment_category per_assignments_f.employment_category%TYPE := 'test';
5361 prev_sex per_people_f.sex%TYPE := 'test';
5362 prev_naic_code hr_lookups.lookup_code%TYPE;
5363
5364 cursor cur_meaning is select
5365 meaning
5366 from
5367 hr_lookups
5368 where
5369 upper(ltrim(rtrim(lookup_type)))='CA_PROVINCE' and
5370 upper(ltrim(rtrim(lookup_code)))=upper(ltrim(rtrim(v_province)));
5371
5372 v_province_name hr_lookups.meaning%TYPE;
5373 prev_province_name hr_lookups.meaning%TYPE;
5374
5375 cursor cur_promoted(desig NUMBER) is
5376 select
5377 count(distinct person_id) count,
5378 meaning meaning,
5379 employment_category employment_category,
5380 sex sex,
5381 province province
5382 from
5383 (
5384 select
5385 paf.person_id person_id,
5386 hl.meaning meaning,
5387 substr(paf.employment_category,1,2) employment_category,
5388 ppf.sex sex,
5389 hl1.region_1 province
5390 from
5391 hr_lookups hl,
5392 per_jobs pj,
5393 per_assignments_f paf,
5394 per_people_f ppf,
5395 per_person_types ppt,
5396 hr_locations hl1,
5397 per_ca_ee_report_lines pert,
5401 upper(ltrim(rtrim(hl.lookup_type)))='EEOG' and
5398 hr_lookups hl2,
5399 hr_soft_coding_keyflex hsck
5400 where
5402 upper(ltrim(rtrim(hl.lookup_code)))=upper(ltrim(ltrim(pj.job_information1))) and
5403 upper(ltrim(rtrim(pj.job_information_category))) = 'CA' and
5404 pj.job_id=paf.job_id and
5405 paf.primary_flag = 'Y' and
5406 --decode(paf.employment_category,'PT',p_date_tmp_emp,l_year_end) between
5407 -- ppf.effective_start_date and
5408 -- ppf.effective_end_date and
5409 ppf.start_date between
5410 paf.effective_start_date and
5411 paf.effective_end_date and
5412 paf.employment_category is not null and
5413 substr(paf.employment_category,1,2) in ('FR','PR','PT')and
5414 paf.person_id=ppf.person_id and
5415 --decode(paf.employment_category,'PT',p_date_tmp_emp,l_year_end) between
5416 -- ppf.effective_start_date and
5417 -- ppf.effective_end_date and
5418 ppf.effective_start_date < l_year_end and
5419 ppf.effective_end_date > l_year_start and
5420 ppf.person_type_id=ppt.person_type_id and
5421 upper(ltrim(rtrim(ppt.system_person_type)))='EMP' and
5422 ppf.business_group_id=p_business_group_id and
5423 paf.location_id=hl1.location_id and
5424 hl1.region_1=hl2.lookup_code and
5425 hl2.lookup_type='CA_PROVINCE' and
5426 pert.request_id=p_request_id and
5427 hl2.meaning=pert.segment2 and
5428 --pert.segment4 = 'Y' and
5429 pert.context='FORM14' and
5430 pert.segment1='PROVINCE' and
5431 decode(desig,1,per_information5,
5432 2,per_information6,
5433 3,per_information7)='Y' and
5434 (
5435 (
5436 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
5437 hsck.segment6 is not null and
5438 hsck.segment6 = v_naic_code
5439 )
5440 OR
5441 (
5442 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
5443 hsck.segment6 is null and
5444 hsck.segment1 in (select segment3
5445 from per_ca_ee_report_lines
5446 where request_id = p_request_id and
5447 context = 'FORM13' and
5448 segment1 = 'NAIC' and
5449 segment2 = v_naic_code)
5450 )
5451 ) and
5452 exists
5453 (
5454 select 'X'
5455 from per_pay_proposals_v2 pppv
5456 where
5457 pppv.assignment_id = paf.assignment_id and
5458 pppv.change_date between l_year_start and
5459 l_year_end and
5460 pppv.approved = 'Y' and
5461 pppv.proposal_reason =
5462 (
5463 select lookup_code
5464 from hr_lookups
5465 where lookup_type = 'PROPOSAL_REASON' and
5466 upper(meaning) = 'PROMOTION'
5467 )
5468 )
5469 union all
5470 select
5471 paf.person_id person_id,
5472 hl.meaning meaning,
5473 'FR' employment_category,
5474 ppf.sex sex,
5475 hl1.region_1 province
5476 from
5477 hr_lookups hl,
5478 per_jobs pj,
5479 per_assignments_f paf,
5480 per_people_f ppf,
5481 per_person_types ppt,
5482 hr_locations hl1,
5483 per_ca_ee_report_lines pert,
5484 hr_lookups hl2,
5485 hr_soft_coding_keyflex hsck
5486 where
5487 upper(ltrim(rtrim(hl.lookup_type)))='EEOG' and
5488 upper(ltrim(rtrim(hl.lookup_code)))=upper(ltrim(ltrim(pj.job_information1))) and
5489 upper(ltrim(rtrim(pj.job_information_category))) = 'CA' and
5490 pj.job_id=paf.job_id and
5491 paf.primary_flag = 'Y' and
5492 --l_year_end between
5493 -- paf.effective_start_date and
5494 -- paf.effective_end_date and
5495 ppf.effective_start_date between
5496 paf.effective_start_date and
5497 paf.effective_end_date and
5498 (paf.employment_category is null OR
5499 substr(paf.employment_category,1,2) not in ('FR','PR','PT'))and
5500 paf.person_id=ppf.person_id and
5501 --l_year_end between
5502 -- ppf.effective_start_date and
5503 -- ppf.effective_end_date and
5504 ppf.effective_start_date < l_year_end and
5505 ppf.effective_end_date > l_year_start and
5506 ppf.person_type_id=ppt.person_type_id and
5507 upper(ltrim(rtrim(ppt.system_person_type)))='EMP' and
5508 ppf.business_group_id=p_business_group_id and
5509 paf.location_id=hl1.location_id and
5510 hl1.region_1=hl2.lookup_code and
5511 hl2.lookup_type='CA_PROVINCE' and
5512 pert.request_id=p_request_id and
5513 hl2.meaning=pert.segment2 and
5514 --pert.segment4 = 'Y' and
5515 pert.context='FORM14' and
5516 pert.segment1='PROVINCE' and
5517 decode(desig,1,per_information5,
5518 2,per_information6,
5519 3,per_information7)='Y' and
5520 (
5521 (
5522 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
5523 hsck.segment6 is not null and
5524 hsck.segment6 = v_naic_code
5525 )
5526 OR
5527 (
5528 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
5529 hsck.segment6 is null and
5530 hsck.segment1 in (select segment3
5531 from per_ca_ee_report_lines
5532 where request_id = p_request_id and
5533 context = 'FORM13' and
5534 segment1 = 'NAIC' and
5535 segment2 = v_naic_code)
5536 )
5537 ) and
5538 exists
5539 (
5540 select 'X'
5541 from per_pay_proposals_v2 pppv
5542 where
5543 pppv.assignment_id = paf.assignment_id and
5544 pppv.approved = 'Y'and
5545 pppv.change_date between l_year_start and
5546 l_year_end and
5547 pppv.proposal_reason =
5548 (
5549 select lookup_code
5550 from hr_lookups
5551 where lookup_type = 'PROPOSAL_REASON' and
5552 upper(meaning) = 'PROMOTION'
5553 )
5554 )
5555 )
5556 group by province,meaning,employment_category,sex
5557 order by province,meaning,employment_category,sex;
5558
5559 cursor cur_eeog is
5560 select
5561 meaning
5562 from
5563 hr_lookups
5564 where
5565 lookup_type='EEOG';
5566
5567 cursor cur_notfound(p_emp_cat number) is
5568 select
5569 segment2,
5570 v_meaning,
5571 decode(p_emp_cat,1,'FR',2,'PR',3,'PT') emp_category
5572 from
5573 per_ca_ee_report_lines where
5574 request_id=p_request_id and
5575 context='FORM14' and
5576 segment1='PROVINCE' and
5577 segment3 <> '0'
5578 minus
5579 select
5580 segment2,
5581 segment3,
5582 segment4
5583 from
5584 per_ca_ee_report_lines
5585 where
5586 request_id=p_request_id and
5587 context='FORM5' and
5588 segment1='PROVINCE'and
5589 segment21 = v_naic_code;
5590
5591 cursor cur_count_national is
5592 select
5593 segment3,
5594 segment4,
5595 sum(to_number(segment5)) segment5,
5596 sum(to_number(segment6)) segment6,
5597 sum(to_number(segment7)) segment7,
5598 sum(to_number(segment8)) segment8,
5599 sum(to_number(segment9)) segment9,
5600 sum(to_number(segment10)) segment10,
5601 sum(to_number(segment11)) segment11,
5602 sum(to_number(segment12)) segment12,
5603 sum(to_number(segment13)) segment13,
5604 sum(to_number(segment14)) segment14,
5605 sum(to_number(segment15)) segment15,
5606 sum(to_number(segment16)) segment16
5607 from
5608 per_ca_ee_report_lines
5609 where
5610 request_id = p_request_id and
5611 context = 'FORM5' and
5612 segment1 = 'PROVINCE' and
5613 segment21 = v_naic_code
5614 group by segment3,segment4;
5615
5616 cursor cur_count_promotions is
5617 select
5618 count(count_total) count_total,
5619 sex sex,
5620 employment_category employment_category,
5621 province province
5622 from
5623 (
5624 select
5625 paf.person_id count_total,
5626 ppf.sex sex,
5627 substr(paf.employment_category,1,2) employment_category,
5628 hl1.region_1 province
5629 from
5630 hr_lookups hl,
5631 per_jobs pj,
5632 per_assignments_f paf,
5633 per_people_f ppf,
5634 per_person_types ppt,
5635 hr_locations hl1,
5636 per_ca_ee_report_lines pert,
5637 hr_lookups hl2,
5638 hr_soft_coding_keyflex hsck,
5639 per_pay_proposals_v2 pppv
5640 where
5641 hl.lookup_type='EEOG' and
5642 upper(ltrim(rtrim(hl.lookup_code)))
5643 =upper(ltrim(rtrim(pj.job_information1))) and
5644 upper(ltrim(rtrim(pj.job_information_category))) = 'CA' and
5645 pj.job_id=paf.job_id and
5646 paf.primary_flag = 'Y' and
5647 --decode(paf.employment_category,'PT',p_date_tmp_emp,l_year_end) between
5648 -- paf.effective_start_date and
5649 -- paf.effective_end_date and
5650 ppf.start_date between
5651 paf.effective_start_date and
5652 paf.effective_end_date and
5653 paf.employment_category is not null and
5654 substr(paf.employment_category,1,2) in ('FR','PR','PT') and
5655 paf.person_id=ppf.person_id and
5656 --decode(paf.employment_category,'PT',p_date_tmp_emp,l_year_end) between
5657 -- ppf.effective_start_date and
5658 -- ppf.effective_end_date and
5659 ppf.effective_start_date < l_year_end and
5660 ppf.effective_end_date > l_year_start and
5661 ppf.person_type_id=ppt.person_type_id and
5662 upper(ltrim(rtrim(ppt.system_person_type)))='EMP' and
5663 ppf.business_group_id=p_business_group_id and
5664 paf.location_id=hl1.location_id and
5665 hl1.region_1=hl2.lookup_code and
5666 hl2.lookup_type='CA_PROVINCE' and
5667 pert.request_id=p_request_id and
5668 hl2.meaning=pert.segment2 and
5669 --pert.segment4 = 'Y' and
5670 pert.context='FORM14' and
5671 pert.segment1='PROVINCE' and
5672 (
5673 (
5674 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
5675 hsck.segment6 is not null and
5676 hsck.segment6 = v_naic_code
5677 )
5678 OR
5679 (
5680 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
5681 hsck.segment6 is null and
5682 hsck.segment1 in (select segment3
5683 from per_ca_ee_report_lines
5684 where request_id = p_request_id and
5685 context = 'FORM13' and
5686 segment1 = 'NAIC' and
5687 segment2 = v_naic_code)
5688 )
5689 ) and
5690 pppv.assignment_id = paf.assignment_id and
5691 pppv.approved = 'Y' and
5692 pppv.change_date between l_year_start and
5693 l_year_end and
5694 pppv.proposal_reason =
5695 (
5696 select lookup_code
5697 from hr_lookups
5698 where lookup_type = 'PROPOSAL_REASON' and
5699 upper(meaning) = 'PROMOTION'
5700 )
5701 union all
5702 select
5703 paf.person_id count_total,
5704 ppf.sex sex,
5705 'FR' employment_category,
5706 hl1.region_1 province
5707 from
5708 hr_lookups hl,
5709 per_jobs pj,
5710 per_assignments_f paf,
5711 per_people_f ppf,
5712 per_person_types ppt,
5713 hr_locations hl1,
5714 per_ca_ee_report_lines pert,
5715 hr_lookups hl2,
5716 hr_soft_coding_keyflex hsck,
5717 per_pay_proposals_v2 pppv
5718 where
5719 hl.lookup_type='EEOG' and
5720 upper(ltrim(rtrim(hl.lookup_code)))
5721 =upper(ltrim(rtrim(pj.job_information1))) and
5722 upper(ltrim(rtrim(pj.job_information_category))) = 'CA' and
5723 pj.job_id=paf.job_id and
5724 paf.primary_flag = 'Y' and
5725 --l_year_end between
5726 -- ppf.effective_start_date and
5727 -- ppf.effective_end_date and
5728 ppf.start_date between
5729 paf.effective_start_date and
5730 paf.effective_end_date and
5731 (paf.employment_category is null OR
5732 substr(paf.employment_category,1,2) not in ('FR','PR','PT')) and
5733 paf.person_id=ppf.person_id and
5734 ppf.effective_start_date < l_year_end and
5735 ppf.effective_end_date > l_year_start and
5736 --l_year_end between
5737 -- ppf.effective_start_date and
5738 -- ppf.effective_end_date and
5739 ppf.person_type_id=ppt.person_type_id and
5740 upper(ltrim(rtrim(ppt.system_person_type)))='EMP' and
5741 ppf.business_group_id=p_business_group_id and
5742 paf.location_id=hl1.location_id and
5743 hl1.region_1=hl2.lookup_code and
5744 hl2.lookup_type='CA_PROVINCE' and
5745 pert.request_id=p_request_id and
5746 hl2.meaning=pert.segment2 and
5747 --pert.segment4 = 'Y' and
5748 pert.context='FORM14' and
5749 pert.segment1='PROVINCE' and
5750 (
5751 (
5752 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
5753 hsck.segment6 is not null and
5754 hsck.segment6 = v_naic_code
5755 )
5756 OR
5757 (
5758 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
5759 hsck.segment6 is null and
5760 hsck.segment1 in (select segment3
5761 from per_ca_ee_report_lines
5762 where request_id = p_request_id and
5763 context = 'FORM13' and
5764 segment1 = 'NAIC' and
5765 segment2 = v_naic_code)
5766 )
5767 ) and
5768 pppv.assignment_id = paf.assignment_id and
5769 pppv.approved = 'Y' and
5770 pppv.change_date between l_year_start and
5771 l_year_end and
5772 pppv.proposal_reason =
5773 (
5774 select lookup_code
5775 from hr_lookups
5776 where lookup_type = 'PROPOSAL_REASON' and
5780 group by province,employment_category,sex
5777 upper(meaning) = 'PROMOTION'
5778 )
5779 )
5781 order by province,employment_category,sex;
5782
5783
5784 cursor cur_total_promotions is
5785 select
5786 count(count_total) count_total,
5787 sex sex,
5788 employment_category employment_category,
5789 province province
5790 from
5791 (
5792 select
5793 paf.person_id count_total,
5794 ppf.sex sex,
5795 substr(paf.employment_category,1,2) employment_category,
5796 hl1.region_1 province
5797 from
5798 hr_lookups hl,
5799 per_jobs pj,
5800 per_assignments_f paf,
5801 per_people_f ppf,
5802 per_person_types ppt,
5803 hr_locations hl1,
5804 per_ca_ee_report_lines pert,
5805 hr_lookups hl2,
5806 hr_soft_coding_keyflex hsck,
5807 per_pay_proposals_v2 pppv
5808 where
5809 hl.lookup_type='EEOG' and
5810 upper(ltrim(rtrim(hl.lookup_code)))
5811 =upper(ltrim(rtrim(pj.job_information1))) and
5812 upper(ltrim(rtrim(pj.job_information_category))) = 'CA' and
5813 pj.job_id=paf.job_id and
5814 paf.primary_flag = 'Y' and
5815 --decode(paf.employment_category,'PT',p_date_tmp_emp,l_year_end) between
5816 -- paf.effective_start_date and
5817 -- paf.effective_end_date and
5818 ppf.start_date between
5819 paf.effective_start_date and
5820 paf.effective_end_date and
5821 paf.employment_category is not null and
5822 substr(paf.employment_category,1,2) in ('FR','PR','PT') and
5823 paf.person_id=ppf.person_id and
5824 --decode(paf.employment_category,'PT',p_date_tmp_emp,l_year_end) between
5825 -- ppf.effective_start_date and
5826 -- ppf.effective_end_date and
5827 ppf.effective_start_date < l_year_end and
5828 ppf.effective_end_date > l_year_start and
5829 ppf.person_type_id=ppt.person_type_id and
5830 upper(ltrim(rtrim(ppt.system_person_type)))='EMP' and
5831 ppf.business_group_id=p_business_group_id and
5832 paf.location_id=hl1.location_id and
5833 hl1.region_1=hl2.lookup_code and
5834 hl2.lookup_type='CA_PROVINCE' and
5835 pert.request_id=p_request_id and
5836 hl2.meaning=pert.segment2 and
5837 --pert.segment4 = 'Y' and
5838 pert.context='FORM14' and
5839 pert.segment1='PROVINCE' and
5840 (
5841 (
5842 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
5843 hsck.segment6 is not null and
5844 hsck.segment6 = v_naic_code
5845 )
5846 OR
5847 (
5848 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
5849 hsck.segment6 is null and
5850 hsck.segment1 in (select segment3
5851 from per_ca_ee_report_lines
5852 where request_id = p_request_id and
5853 context = 'FORM13' and
5854 segment1 = 'NAIC' and
5855 segment2 = v_naic_code)
5856 )
5857 ) and
5858 pppv.assignment_id = paf.assignment_id and
5859 pppv.approved = 'Y' and
5860 pppv.change_date between l_year_start and
5861 l_year_end and
5862 pppv.proposal_reason =
5863 (
5864 select lookup_code
5865 from hr_lookups
5866 where lookup_type = 'PROPOSAL_REASON' and
5867 upper(meaning) = 'PROMOTION'
5868 )
5869 union all
5870 select
5871 paf.person_id count_total,
5872 ppf.sex sex,
5873 'FR' employment_category,
5874 hl1.region_1 province
5875 from
5876 hr_lookups hl,
5877 per_jobs pj,
5878 per_assignments_f paf,
5879 per_people_f ppf,
5880 per_person_types ppt,
5881 hr_locations hl1,
5882 per_ca_ee_report_lines pert,
5883 hr_lookups hl2,
5884 hr_soft_coding_keyflex hsck,
5885 per_pay_proposals_v2 pppv
5886 where
5887 hl.lookup_type='EEOG' and
5888 upper(ltrim(rtrim(hl.lookup_code)))
5889 =upper(ltrim(rtrim(pj.job_information1))) and
5890 upper(ltrim(rtrim(pj.job_information_category))) = 'CA' and
5891 pj.job_id=paf.job_id and
5892 paf.primary_flag = 'Y' and
5893 --l_year_end between
5894 -- ppf.effective_start_date and
5895 -- ppf.effective_end_date and
5896 ppf.start_date between
5897 paf.effective_start_date and
5898 paf.effective_end_date and
5899 (paf.employment_category is null OR
5900 substr(paf.employment_category,1,2) not in ('FR','PR','PT')) and
5901 paf.person_id=ppf.person_id and
5902 ppf.effective_start_date < l_year_end and
5903 ppf.effective_end_date > l_year_start and
5904 --l_year_end between
5905 -- ppf.effective_start_date and
5906 -- ppf.effective_end_date and
5907 ppf.person_type_id=ppt.person_type_id and
5908 upper(ltrim(rtrim(ppt.system_person_type)))='EMP' and
5909 ppf.business_group_id=p_business_group_id and
5913 pert.request_id=p_request_id and
5910 paf.location_id=hl1.location_id and
5911 hl1.region_1=hl2.lookup_code and
5912 hl2.lookup_type='CA_PROVINCE' and
5914 hl2.meaning=pert.segment2 and
5915 --pert.segment4 = 'Y' and
5916 pert.context='FORM14' and
5917 pert.segment1='PROVINCE' and
5918 (
5919 (
5920 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
5921 hsck.segment6 is not null and
5922 hsck.segment6 = v_naic_code
5923 )
5924 OR
5925 (
5926 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
5927 hsck.segment6 is null and
5928 hsck.segment1 in (select segment3
5929 from per_ca_ee_report_lines
5930 where request_id = p_request_id and
5931 context = 'FORM13' and
5932 segment1 = 'NAIC' and
5933 segment2 = v_naic_code)
5934 )
5935 ) and
5936 pppv.assignment_id = paf.assignment_id and
5937 pppv.approved = 'Y' and
5938 pppv.change_date between l_year_start and
5939 l_year_end and
5940 pppv.proposal_reason =
5941 (
5942 select lookup_code
5943 from hr_lookups
5944 where lookup_type = 'PROPOSAL_REASON' and
5945 upper(meaning) = 'PROMOTION'
5946 )
5947 )
5948 group by province,employment_category,sex
5949 order by province,employment_category,sex;
5950
5951 cursor cur_promotions(desig number) is
5952 select
5953 count(person_id) count,
5954 employment_category employment_category,
5955 sex sex,
5956 province province
5957 from
5958 (
5959 select
5960 paf.person_id person_id,
5961 substr(paf.employment_category,1,2) employment_category,
5962 ppf.sex sex,
5963 hl1.region_1 province
5964 from
5965 hr_lookups hl,
5966 per_jobs pj,
5967 per_assignments_f paf,
5968 per_people_f ppf,
5969 per_person_types ppt,
5970 hr_locations hl1,
5971 per_ca_ee_report_lines pert,
5972 hr_lookups hl2,
5973 hr_soft_coding_keyflex hsck,
5974 per_pay_proposals_v2 pppv
5975 where
5976 upper(ltrim(rtrim(hl.lookup_type)))='EEOG' and
5977 upper(ltrim(rtrim(hl.lookup_code)))
5978 = upper(ltrim(ltrim(pj.job_information1))) and
5979 upper(ltrim(rtrim(pj.job_information_category))) = 'CA' and
5980 pj.job_id=paf.job_id and
5981 paf.primary_flag = 'Y' and
5982 --decode(paf.employment_category,'PT',p_date_tmp_emp,l_year_end) between
5983 -- ppf.effective_start_date and
5984 -- ppf.effective_end_date and
5985 ppf.start_date between
5986 paf.effective_start_date and
5987 paf.effective_end_date and
5988 paf.employment_category is not null and
5989 substr(paf.employment_category,1,2) in ('FR','PR','PT')and
5990 paf.person_id=ppf.person_id and
5991 --decode(paf.employment_category,'PT',p_date_tmp_emp,l_year_end) between
5992 -- ppf.effective_start_date and
5993 -- ppf.effective_end_date and
5994 ppf.effective_start_date < l_year_end and
5995 ppf.effective_end_date > l_year_start and
5996 ppf.person_type_id=ppt.person_type_id and
5997 upper(ltrim(rtrim(ppt.system_person_type)))='EMP' and
5998 ppf.business_group_id=p_business_group_id and
5999 paf.location_id=hl1.location_id and
6000 hl1.region_1=hl2.lookup_code and
6001 hl2.lookup_type='CA_PROVINCE' and
6002 pert.request_id=p_request_id and
6003 hl2.meaning=pert.segment2 and
6004 --pert.segment4 = 'Y' and
6005 pert.context='FORM14' and
6006 pert.segment1='PROVINCE' and
6007 decode(desig,1,per_information5,
6008 2,per_information6,
6009 3,per_information7)='Y' and
6010 (
6011 (
6012 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
6013 hsck.segment6 is not null and
6014 hsck.segment6 = v_naic_code
6015 )
6016 OR
6017 (
6018 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
6019 hsck.segment6 is null and
6020 hsck.segment1 in (select segment3
6021 from per_ca_ee_report_lines
6022 where request_id = p_request_id and
6023 context = 'FORM13' and
6024 segment1 = 'NAIC' and
6025 segment2 = v_naic_code)
6026 )
6027 ) and
6028 pppv.assignment_id = paf.assignment_id and
6029 pppv.change_date between l_year_start and
6030 l_year_end and
6031 pppv.approved = 'Y' and
6032 pppv.proposal_reason =
6033 (
6034 select lookup_code
6035 from hr_lookups
6036 where lookup_type = 'PROPOSAL_REASON' and
6037 upper(meaning) = 'PROMOTION'
6038 )
6039 union all
6040 select
6041 paf.person_id person_id,
6042 'FR' employment_category,
6043 ppf.sex sex,
6044 hl1.region_1 province
6045 from
6046 hr_lookups hl,
6047 per_jobs pj,
6048 per_assignments_f paf,
6049 per_people_f ppf,
6050 per_person_types ppt,
6054 hr_soft_coding_keyflex hsck,
6051 hr_locations hl1,
6052 per_ca_ee_report_lines pert,
6053 hr_lookups hl2,
6055 per_pay_proposals_v2 pppv
6056 where
6057 upper(ltrim(rtrim(hl.lookup_type)))='EEOG' and
6058 upper(ltrim(rtrim(hl.lookup_code)))
6059 = upper(ltrim(ltrim(pj.job_information1))) and
6060 upper(ltrim(rtrim(pj.job_information_category))) = 'CA' and
6061 pj.job_id=paf.job_id and
6062 paf.primary_flag = 'Y' and
6063 --l_year_end between
6064 -- paf.effective_start_date and
6065 -- paf.effective_end_date and
6066 ppf.effective_start_date between
6067 paf.effective_start_date and
6068 paf.effective_end_date and
6069 (paf.employment_category is null OR
6070 substr(paf.employment_category,1,2) not in ('FR','PR','PT'))and
6071 paf.person_id=ppf.person_id and
6072 --l_year_end between
6073 -- ppf.effective_start_date and
6074 -- ppf.effective_end_date and
6075 ppf.effective_start_date < l_year_end and
6076 ppf.effective_end_date > l_year_start and
6077 ppf.person_type_id=ppt.person_type_id and
6078 upper(ltrim(rtrim(ppt.system_person_type)))='EMP' and
6079 ppf.business_group_id=p_business_group_id and
6080 paf.location_id=hl1.location_id and
6081 hl1.region_1=hl2.lookup_code and
6082 hl2.lookup_type='CA_PROVINCE' and
6083 pert.request_id=p_request_id and
6084 hl2.meaning=pert.segment2 and
6085 --pert.segment4 = 'Y' and
6086 pert.context='FORM14' and
6087 pert.segment1='PROVINCE' and
6088 decode(desig,1,per_information5,
6089 2,per_information6,
6090 3,per_information7)='Y' and
6091 (
6092 (
6093 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
6094 hsck.segment6 is not null and
6095 hsck.segment6 = v_naic_code
6096 )
6097 OR
6098 (
6099 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
6100 hsck.segment6 is null and
6101 hsck.segment1 in (select segment3
6102 from per_ca_ee_report_lines
6103 where request_id = p_request_id and
6104 context = 'FORM13' and
6105 segment1 = 'NAIC' and
6106 segment2 = v_naic_code)
6107 )
6108 ) and
6109 pppv.assignment_id = paf.assignment_id and
6110 pppv.approved = 'Y'and
6111 pppv.change_date between l_year_start and
6112 l_year_end and
6113 pppv.proposal_reason =
6114 (
6115 select lookup_code
6116 from hr_lookups
6117 where lookup_type = 'PROPOSAL_REASON' and
6118 upper(meaning) = 'PROMOTION'
6119 )
6120 )
6121 group by province,employment_category,sex
6122 order by province,employment_category,sex;
6123
6124 cursor cur_count_national_promotions is
6125 select
6126 segment3,
6127 sum(to_number(segment4)) segment4,
6128 sum(to_number(segment5)) segment5,
6129 sum(to_number(segment6)) segment6,
6130 sum(to_number(segment7)) segment7,
6131 sum(to_number(segment8)) segment8,
6132 sum(to_number(segment9)) segment9,
6133 sum(to_number(segment10)) segment10,
6134 sum(to_number(segment11)) segment11,
6135 sum(to_number(segment12)) segment12,
6136 sum(to_number(segment13)) segment13,
6137 sum(to_number(segment14)) segment14,
6138 sum(to_number(segment15)) segment15
6139 from
6140 per_ca_ee_report_lines
6141 where
6142 request_id = p_request_id and
6143 context = 'FORM5P' and
6144 segment1 = 'PROVINCE' and
6145 segment21 = v_naic_code
6146 group by segment3;
6147
6148 cursor cur_notfound_promotions(emp_cat number) is
6149 select
6150 segment2,
6151 decode(emp_cat,1,'FR','2','PR',3,'PT') emp_category
6152 from
6153 per_ca_ee_report_lines
6154 where
6155 request_id = p_request_id and
6156 segment3 <> '0' and
6157 context = 'FORM14'
6158 minus
6159 select
6160 segment2,
6161 segment3
6162 from
6163 per_ca_ee_report_lines
6164 where
6165 request_id = p_request_id and
6166 context = 'FORM5P' and
6167 segment1 = 'PROVINCE' ;
6168
6169 begin
6170
6171 for naic in cur_naic loop
6172
6173 v_naic_code := naic.naic_code;
6174
6175 hr_utility.trace('Form5: v_naic = ' || v_naic_code );
6176
6177 for j in cur_promoted_total
6178 loop
6179 v_count := j.count_total;
6180 v_meaning := j.meaning;
6181 v_employment_category := j.employment_category;
6182 v_sex := j.sex;
6183 v_province := j.province;
6184
6185 open cur_meaning;
6186 fetch cur_meaning into v_province_name;
6187 close cur_meaning;
6188
6189 if ((ltrim(rtrim(v_province_name))
6190 <>ltrim(rtrim(prev_province_name))) or
6191 (ltrim(rtrim(prev_meaning)) <> ltrim(rtrim(v_meaning))) or
6192 (ltrim(rtrim(prev_naic_code)) <> ltrim(rtrim(v_naic_code))) or
6193 (ltrim(rtrim(prev_employment_category)) <>
6194 ltrim(rtrim(v_employment_category)))) then
6195
6196 per_ca_ee_extract_pkg.k := per_ca_ee_extract_pkg.k + 1;
6197
6198 insert into per_ca_ee_report_lines
6199 (request_id,
6200 line_number,
6204 segment3,
6201 context,
6202 segment1,
6203 segment2,
6205 segment4,
6206 segment5,
6207 segment6,
6208 segment7,
6209 segment8,
6210 segment9,
6211 segment10,
6212 segment11,
6213 segment12,
6214 segment13,
6215 segment14,
6216 segment15,
6217 segment16,
6218 segment21) values
6219 ( p_request_id,
6220 per_ca_ee_extract_pkg.k,
6221 'FORM5',
6222 'PROVINCE',
6223 v_province_name,
6224 v_meaning,
6225 v_employment_category,
6226 nvl(v_count,0),
6227 decode(v_sex,'F',v_count,0),
6228 decode(v_sex,'M',v_count,0),
6229 '0',
6230 '0',
6231 '0',
6232 '0',
6233 '0',
6234 '0',
6235 '0',
6236 '0',
6237 '0',
6238 v_naic_code);
6239 else
6240
6241 if prev_province_name = v_province_name and
6242 prev_meaning = v_meaning and
6243 prev_naic_code = v_naic_code and
6244 prev_employment_category = v_employment_category and
6245 prev_sex <> v_sex then
6246
6247 if v_sex = 'M' then
6248
6249 update per_ca_ee_report_lines set
6250 segment7=nvl(v_count,0),
6251 segment5=segment5 + nvl(v_count,0)
6252 where request_id=p_request_id and
6253 line_number = per_ca_ee_extract_pkg.k and
6254 context='FORM5' and
6255 segment1='PROVINCE' and
6256 segment2=v_province_name and
6257 segment3=v_meaning and
6258 segment4=v_employment_category and
6259 segment21=v_naic_code;
6260
6261 elsif v_sex = 'F' then
6262
6263 update per_ca_ee_report_lines set
6264 segment6=nvl(v_count,0),
6265 segment5=segment5 + nvl(v_count,0)
6266 where request_id=p_request_id and
6267 line_number = per_ca_ee_extract_pkg.k and
6268 context='FORM5' and
6269 segment1='PROVINCE' and
6270 segment2=v_province_name and
6271 segment3=v_meaning and
6272 segment4=v_employment_category and
6273 segment21=v_naic_code;
6274
6275 end if;
6276
6277 end if;
6278 end if;
6279
6280 prev_meaning := v_meaning;
6281 prev_employment_category := v_employment_category;
6282 prev_sex := v_sex;
6283 prev_province_name := v_province_name;
6284 prev_naic_code := v_naic_code;
6285
6286 end loop; -- End loop cur_promoted_total
6287
6288 for i in 1..3 loop
6289
6290 for j in cur_promoted(i)
6291 loop
6292
6293 v_sex := j.sex;
6294 v_employment_category := j.employment_category;
6295 v_meaning := j.meaning;
6296 v_count := j.count;
6297 v_province := j.province;
6298
6299 open cur_meaning;
6300 fetch cur_meaning into v_province_name;
6301 close cur_meaning;
6302
6303
6304 if i = 1 then
6305
6306 if v_sex = 'M' then
6307
6308 update per_ca_ee_report_lines set
6309 segment8 = nvl(segment8,0) + nvl(v_count,0),
6310 segment10 = nvl(v_count,0)
6311 where
6312 request_id = p_request_id and
6313 context = 'FORM5' and
6314 segment1 = 'PROVINCE' and
6315 segment2 = v_province_name and
6316 segment3 = v_meaning and
6317 segment4 = v_employment_category and
6318 segment21 = v_naic_code;
6319
6320 elsif v_sex = 'F' then
6321
6322 update per_ca_ee_report_lines set
6323 segment8 = nvl(segment8,0) + nvl(v_count,0),
6324 segment9 = nvl(v_count,0)
6325 where
6326 request_id = p_request_id and
6327 context = 'FORM5' and
6328 segment1 = 'PROVINCE' and
6329 segment2 = v_province_name and
6330 segment3 = v_meaning and
6331 segment4 = v_employment_category and
6332 segment21 = v_naic_code;
6333
6334 end if;
6335
6336 elsif i = 2 then
6337
6338 if v_sex = 'M' then
6339
6340 update per_ca_ee_report_lines set
6341 segment11 = nvl(segment11,0) + nvl(v_count,0),
6342 segment13 = nvl(v_count,0)
6343 where
6344 request_id = p_request_id and
6345 context = 'FORM5' and
6346 segment1 = 'PROVINCE' and
6347 segment2 = v_province_name and
6348 segment3 = v_meaning and
6349 segment4 = v_employment_category and
6350 segment21 = v_naic_code;
6351
6352 elsif v_sex = 'F' then
6353
6354 update per_ca_ee_report_lines set
6355 segment11 = nvl(segment11,0) + nvl(v_count,0),
6356 segment12 = nvl(v_count,0)
6357 where
6358 request_id = p_request_id and
6359 context = 'FORM5' and
6360 segment1 = 'PROVINCE' and
6361 segment2 = v_province_name and
6362 segment3 = v_meaning and
6363 segment4 = v_employment_category and
6364 segment21 = v_naic_code;
6365
6366 end if;
6367
6368 elsif i = 3 then
6369
6370 if v_sex = 'M' then
6371
6372 update per_ca_ee_report_lines set
6373 segment14 = nvl(segment14,0) + nvl(v_count,0),
6374 segment16 = nvl(v_count,0)
6375 where
6376 request_id = p_request_id and
6377 context = 'FORM5' and
6378 segment1 = 'PROVINCE' and
6379 segment2 = v_province_name and
6380 segment3 = v_meaning and
6381 segment4 = v_employment_category and
6382 segment21 = v_naic_code;
6383
6384 elsif v_sex = 'F' then
6385
6386 update per_ca_ee_report_lines set
6387 segment14 = nvl(segment14,0) + nvl(v_count,0),
6388 segment15 = nvl(v_count,0)
6389 where
6390 request_id = p_request_id and
6391 context = 'FORM5' and
6392 segment1 = 'PROVINCE' and
6393 segment2 = v_province_name and
6394 segment3 = v_meaning and
6395 segment4 = v_employment_category and
6396 segment21 = v_naic_code;
6397
6398 end if;
6399 end if;
6400 end loop; -- End loop cur_hired
6401 end loop; -- End loop Designated Group
6402
6403 for i in cur_eeog loop
6404
6405 v_meaning := i.meaning;
6406
6407 hr_utility.trace('Form5: cur_eeog: v_eeog' || v_meaning);
6408
6409 for emp_cat in 1..3 loop
6410
6411 for x in cur_notfound(emp_cat) loop
6412
6413 per_ca_ee_extract_pkg.k := per_ca_ee_extract_pkg.k + 1;
6414
6415 insert into per_ca_ee_report_lines
6416 (request_id,
6417 line_number,
6418 context,
6419 segment1,
6420 segment2,
6421 segment3,
6422 segment4,
6423 segment5,
6424 segment6,
6425 segment7,
6426 segment8,
6427 segment9,
6428 segment10,
6429 segment11,
6430 segment12,
6431 segment13,
6432 segment14,
6433 segment15,
6434 segment16,
6435 segment21) values
6436 ( p_request_id,
6437 per_ca_ee_extract_pkg.k,
6438 'FORM5',
6439 'PROVINCE',
6440 x.segment2,
6441 v_meaning,
6442 x.emp_category,
6443 0,
6444 0,
6445 0,
6446 0,
6447 0,
6448 0,
6449 0,
6450 0,
6451 0,
6452 0,
6453 0,
6454 0,
6455 v_naic_code);
6456
6457 end loop; -- End loop cur_notfound
6458
6459 end loop; -- End loop emp_cat
6460
6461 end loop; -- End loop cur_eeog
6462
6463 prev_province_name := 'test';
6464 prev_employment_category := 'te';
6465 prev_naic_code := 'te';
6466
6467 for i in cur_total_promotions loop
6468
6469 hr_utility.trace('Form5P: cur_total_promotions');
6470
6471 v_count := i.count_total;
6472 v_employment_category := i.employment_category;
6473 v_sex := i.sex;
6474 v_province := i.province;
6475
6476 open cur_meaning;
6477 fetch cur_meaning into v_province_name;
6478 close cur_meaning;
6479
6480 hr_utility.trace('Form5P: prev_province_name: ' || prev_province_name);
6481 hr_utility.trace('Form5P: v_province_name: ' || v_province_name);
6482 hr_utility.trace('Form5P: prev_naic_code: ' || prev_naic_code);
6483 hr_utility.trace('Form5P: v_naic_code: ' || v_naic_code);
6484 hr_utility.trace('Form5P: prev_emp_category: ' || prev_employment_category);
6485 hr_utility.trace('Form5P: v_emp_category: ' || v_employment_category);
6486
6487 if ((ltrim(rtrim(v_province_name))
6488 <>ltrim(rtrim(prev_province_name))) or
6489 (ltrim(rtrim(prev_naic_code)) <> ltrim(rtrim(v_naic_code))) or
6490 (ltrim(rtrim(prev_employment_category)) <>
6491 ltrim(rtrim(v_employment_category)))) then
6492
6493 hr_utility.trace('Form5P: cur_total_promotions : Inside If');
6494 per_ca_ee_extract_pkg.k := per_ca_ee_extract_pkg.k + 1;
6495
6496 insert into per_ca_ee_report_lines
6497 (request_id,
6498 line_number,
6499 context,
6500 segment1,
6501 segment2,
6502 segment3,
6503 segment4,
6504 segment5,
6505 segment6,
6506 segment7,
6507 segment8,
6508 segment9,
6509 segment10,
6510 segment11,
6511 segment12,
6512 segment13,
6513 segment14,
6514 segment15,
6515 segment21) values
6516 (p_request_id,
6517 per_ca_ee_extract_pkg.k,
6518 'FORM5P',
6519 'PROVINCE',
6520 v_province_name,
6521 v_employment_category,
6522 nvl(v_count,0),
6523 decode(v_sex,'M',v_count,0),
6524 decode(v_sex,'F',v_count,0),
6525 '0',
6526 '0',
6527 '0',
6528 '0',
6529 '0',
6530 '0',
6531 '0',
6532 '0',
6533 '0',
6534 v_naic_code);
6535
6536 else
6537
6538 if prev_province_name = v_province_name and
6539 prev_naic_code = v_naic_code and
6540 prev_employment_category = v_employment_category and
6541 prev_sex <> v_sex then
6542
6543 if v_sex = 'M' then
6544
6545 update per_ca_ee_report_lines set
6546 segment5=nvl(v_count,0),
6547 segment4=segment4 + nvl(v_count,0)
6548 where request_id=p_request_id and
6549 line_number = per_ca_ee_extract_pkg.k and
6550 context='FORM5P' and
6551 segment1='PROVINCE' and
6552 segment2=v_province_name and
6553 segment3=v_employment_category and
6554 segment21=v_naic_code;
6555
6556 elsif v_sex = 'F' then
6557
6558 update per_ca_ee_report_lines set
6559 segment6=nvl(v_count,0),
6560 segment4=segment4 + nvl(v_count,0)
6561 where request_id=p_request_id and
6562 line_number = per_ca_ee_extract_pkg.k and
6563 context='FORM5P' and
6564 segment1='PROVINCE' and
6565 segment2=v_province_name and
6566 segment3=v_employment_category and
6567 segment21=v_naic_code;
6568
6569 end if;
6570
6571 end if;
6572
6573 end if;
6574
6578
6575 prev_meaning := v_meaning;
6576 prev_employment_category := v_employment_category;
6577 prev_sex := v_sex;
6579 end loop; -- End loop cur_total_promotions
6580
6581 for i in 1..3 loop
6582
6583 for j in cur_promotions(i) loop
6584
6585 v_sex := j.sex;
6586 v_employment_category := j.employment_category;
6587 --v_meaning := j.meaning;
6588 v_count := j.count;
6589 v_province := j.province;
6590
6591 open cur_meaning;
6592 fetch cur_meaning into v_province_name;
6593 close cur_meaning;
6594
6595
6596 if i = 1 then
6597
6598 if v_sex = 'M' then
6599
6600 update per_ca_ee_report_lines set
6601 segment7 = nvl(segment7,0) + nvl(v_count,0),
6602 segment8 = nvl(v_count,0)
6603 where
6604 request_id = p_request_id and
6605 context = 'FORM5P' and
6606 segment1 = 'PROVINCE' and
6607 segment2 = v_province_name and
6608 segment3 = v_employment_category and
6609 segment21 = v_naic_code;
6610
6611 elsif v_sex = 'F' then
6612
6613 update per_ca_ee_report_lines set
6614 segment7 = nvl(segment7,0) + nvl(v_count,0),
6615 segment9 = nvl(v_count,0)
6616 where
6617 request_id = p_request_id and
6618 context = 'FORM5P' and
6619 segment1 = 'PROVINCE' and
6620 segment2 = v_province_name and
6621 segment3 = v_employment_category and
6622 segment21 = v_naic_code;
6623
6624 end if;
6625
6626 elsif i = 2 then
6627
6628 if v_sex = 'M' then
6629
6630 update per_ca_ee_report_lines set
6631 segment10 = nvl(segment10,0) + nvl(v_count,0),
6632 segment11 = nvl(v_count,0)
6633 where
6634 request_id = p_request_id and
6635 context = 'FORM5P' and
6636 segment1 = 'PROVINCE' and
6637 segment2 = v_province_name and
6638 segment3 = v_employment_category and
6639 segment21 = v_naic_code;
6640
6641 elsif v_sex = 'F' then
6642
6643 update per_ca_ee_report_lines set
6644 segment10 = nvl(segment10,0) + nvl(v_count,0),
6645 segment12 = nvl(v_count,0)
6646 where
6647 request_id = p_request_id and
6648 context = 'FORM5P' and
6649 segment1 = 'PROVINCE' and
6650 segment2 = v_province_name and
6651 segment3 = v_employment_category and
6652 segment21 = v_naic_code;
6653
6654 end if;
6655
6656 elsif i = 3 then
6657
6658 if v_sex = 'M' then
6659
6660 update per_ca_ee_report_lines set
6661 segment13 = nvl(segment13,0) + nvl(v_count,0),
6662 segment14 = nvl(v_count,0)
6663 where
6664 request_id = p_request_id and
6665 context = 'FORM5P' and
6666 segment1 = 'PROVINCE' and
6667 segment2 = v_province_name and
6668 segment3 = v_employment_category and
6669 segment21 = v_naic_code;
6670
6671 elsif v_sex = 'F' then
6672
6673 update per_ca_ee_report_lines set
6674 segment13 = nvl(segment13,0) + nvl(v_count,0),
6675 segment15 = nvl(v_count,0)
6676 where
6677 request_id = p_request_id and
6678 context = 'FORM5P' and
6679 segment1 = 'PROVINCE' and
6680 segment2 = v_province_name and
6681 segment3 = v_employment_category and
6682 segment21 = v_naic_code;
6683
6684 end if;
6685
6686 end if;
6687
6688 end loop; -- End loop cur_promotions.
6689
6690 end loop; -- End loop for designated group members.
6691
6692 for i in 1..3 loop
6693 for j in cur_notfound_promotions(i) loop
6694
6695 insert into per_ca_ee_report_lines
6696 (request_id,
6697 line_number,
6698 context,
6699 segment1,
6700 segment2,
6701 segment3,
6702 segment4,
6703 segment5,
6704 segment6,
6705 segment7,
6706 segment8,
6707 segment9,
6708 segment10,
6709 segment11,
6710 segment12,
6711 segment13,
6712 segment14,
6713 segment15,
6714 segment21) values
6715 (p_request_id,
6716 per_ca_ee_extract_pkg.k,
6717 'FORM5P',
6718 'PROVINCE',
6719 j.segment2,
6720 j.emp_category,
6721 '0',
6722 '0',
6723 '0',
6724 '0',
6725 '0',
6726 '0',
6727 '0',
6728 '0',
6729 '0',
6730 '0',
6731 '0',
6732 '0',
6733 v_naic_code);
6734
6735 end loop;
6736 end loop; -- End loop for designated group members.
6737
6738 for i in cur_count_national_promotions loop
6739
6740 insert into per_ca_ee_report_lines
6741 (request_id,
6742 line_number,
6743 context,
6744 segment1,
6745 segment2,
6746 segment3,
6747 segment4,
6748 segment5,
6749 segment6,
6750 segment7,
6751 segment8,
6752 segment9,
6753 segment10,
6754 segment11,
6755 segment12,
6756 segment13,
6757 segment14,
6758 segment21) values
6759 (p_request_id,
6760 per_ca_ee_extract_pkg.k,
6761 'FORM5P',
6762 'NATIONAL',
6763 i.segment3,
6764 i.segment4,
6765 i.segment5,
6766 i.segment6,
6767 i.segment7,
6768 i.segment8,
6769 i.segment9,
6770 i.segment10,
6771 i.segment11,
6772 i.segment12,
6773 i.segment13,
6774 i.segment14,
6775 i.segment15,
6776 -- i.segment16,
6777 v_naic_code);
6778
6779 end loop;
6780
6781 for count_national in cur_count_national loop
6782
6783 hr_utility.trace('Form5: cur_count_national. ');
6784
6785 insert into per_ca_ee_report_lines
6786 (request_id,
6787 line_number,
6788 context,
6789 segment1,
6790 segment2,
6791 segment3,
6792 segment4,
6793 segment5,
6794 segment6,
6795 segment7,
6796 segment8,
6797 segment9,
6798 segment10,
6799 segment11,
6800 segment12,
6801 segment13,
6802 segment14,
6803 segment15,
6804 segment21) values
6805 ( p_request_id,
6806 per_ca_ee_extract_pkg.k,
6807 'FORM5',
6808 'NATIONAL',
6809 count_national.segment3,
6810 count_national.segment4,
6811 count_national.segment5,
6812 count_national.segment6,
6813 count_national.segment7,
6814 count_national.segment8,
6815 count_national.segment9,
6816 count_national.segment10,
6817 count_national.segment11,
6818 count_national.segment12,
6819 count_national.segment13,
6820 count_national.segment14,
6821 count_national.segment15,
6822 count_national.segment16,
6823 v_naic_code);
6824
6825 end loop; -- End loop cur_count_total
6826
6827 prev_naic_code := v_naic_code;
6828
6829 end loop; -- End loop cur_naic
6830
6831
6832 return 1;
6833 end;
6834 end form5;
6835 */
6836
6837 function form5(p_business_group_id in number,
6838 p_request_id in number,
6839 p_year in varchar2,
6840 p_date_tmp_emp in date) return number is
6841
6842 l_year_start date;
6843 l_year_end date;
6844
6845 begin
6846
6847 l_year_start := trunc(to_date(p_year,'YYYY'),'Y');
6848 l_year_end := add_months(trunc(to_date(p_year,'YYYY'),'Y'), 12) -1;
6849
6850 declare
6851
6852 cursor cur_naic is
6853 select pert.segment4 naic_code
6854 from per_ca_ee_report_lines pert
6855 where pert.request_id = p_request_id
6856 and pert.context = 'FORM12';
6857
6858 v_naic_code hr_lookups.lookup_code%TYPE;
6859
6860 cursor cur_jobs is
6861 select job_id,
6862 meaning
6863 from per_jobs,
6864 hr_lookups
6865 where lookup_type = 'EEOG'
6866 and upper(ltrim(rtrim(lookup_code)))
6867 =upper(ltrim(rtrim(job_information1)))
6868 and upper(ltrim(rtrim(job_information_category))) = 'CA'
6869 and business_group_id = p_business_group_id;
6870
6871
6872 cursor cur_person_types is
6873 select person_type_id
6874 from per_person_types
6875 where upper(ltrim(rtrim(system_person_type)))='EMP'
6876 and business_group_id = p_business_group_id;
6877
6878 cursor cur_promoted_total(desig number) is
6879 select
6880 sum(employee_total) employee_total,
6881 meaning meaning,
6882 sex sex,
6883 employment_category employment_category,
6884 province province
6885 from
6886 (
6887 select
6888 employee_promotions(paf.assignment_id,
6889 paf.person_id,
6890 p_business_group_id,
6891 l_year_start,
6892 l_year_end,
6893 'Y') employee_total,
6894 job_exists(paf.job_id) meaning,
6895 ppf.sex sex,
6896 substr(paf.employment_category,1,2) employment_category,
6897 hl1.region_1 province
6898 from
6899 per_assignments_f paf,
6900 per_people_f ppf,
6901 hr_locations hl1,
6902 per_ca_ee_report_lines pert,
6903 hr_lookups hl2,
6904 hr_soft_coding_keyflex hsck
6905 where job_exists(paf.job_id) is not null
6906 and paf.primary_flag = 'Y'
6907 and paf.assignment_id =
6908 (select max(pafm.assignment_id) -- This select ensures that
6909 from per_assignments_f pafm -- for rehires only the last
6910 where pafm.person_id = ppf.person_id -- assignment is used
6911 and pafm.primary_flag = 'Y'
6912 and pafm.business_group_id = p_business_group_id)
6913 -- and ppf.start_date between
6914 -- paf.effective_start_date and
6915 -- paf.effective_end_date
6916 and paf.effective_start_date <= l_year_end
6917 and paf.effective_end_date >= l_year_start
6918 and paf.effective_start_date =
6919 (select max(paf_max.effective_start_date) -- The last assignment
6920 from per_assignments_f paf_max -- in the year
6921 where paf_max.assignment_id = paf.assignment_id
6922 and paf_max.primary_flag = 'Y'
6923 and paf_max.effective_start_date <= l_year_end
6924 and paf_max.effective_end_date >= l_year_start
6925 and paf_max.business_group_id = p_business_group_id)
6926 and paf.employment_category is not null
6927 and substr(paf.employment_category,1,2) in ('FR','PR','PT')
6928 and paf.person_id = ppf.person_id
6929 and ppf.effective_start_date <= l_year_end
6930 and ppf.effective_end_date >= l_year_start
6931 and ppf.effective_start_date =
6932 (select max(ppf_max.effective_start_date) -- The last person
6933 from per_people_f ppf_max -- record in the year
6934 where ppf_max.person_id = ppf.person_id
6935 and ppf_max.effective_start_date <= l_year_end
6936 and ppf_max.effective_end_date >= l_year_start
6937 and ppf_max.business_group_id = p_business_group_id
6938 and person_type_exists(ppf_max.person_type_id) is not null)
6939 and person_type_exists(ppf.person_type_id) is not null
6940 and ppf.business_group_id = p_business_group_id
6941 and paf.location_id = hl1.location_id
6942 and hl1.region_1 = hl2.lookup_code
6943 and hl2.lookup_type = 'CA_PROVINCE'
6944 and pert.request_id = p_request_id
6945 and hl2.meaning = pert.segment2
6946 and pert.context = 'FORM14'
6947 and pert.segment1 = 'PROVINCE'
6948 and decode (desig, 0, 'Y',
6949 1, per_information5,
6950 2, per_information6,
6951 3, per_information7) = 'Y'
6952 and (
6953 (
6954 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
6955 hsck.segment6 is not null and
6956 hsck.segment6 = v_naic_code
6957 )
6958 OR
6959 (
6960 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
6961 hsck.segment6 is null and
6962 hsck.segment1 in (select segment3
6963 from per_ca_ee_report_lines
6964 where request_id = p_request_id
6965 and context = 'FORM13'
6966 and segment1 = 'NAIC'
6967 and segment2 = v_naic_code)
6968 )
6969 )
6970 union all
6974 p_business_group_id,
6971 select
6972 employee_promotions(paf.assignment_id,
6973 paf.person_id,
6975 l_year_start,
6976 l_year_end,
6977 'Y') employee_total,
6978 job_exists(paf.job_id) meaning,
6979 ppf.sex sex,
6980 'FR' employment_category,
6981 hl1.region_1 province
6982 from
6983 per_assignments_f paf,
6984 per_people_f ppf,
6985 hr_locations hl1,
6986 per_ca_ee_report_lines pert,
6987 hr_lookups hl2,
6988 hr_soft_coding_keyflex hsck
6989 where
6990 job_exists(paf.job_id) is not null
6991 and paf.primary_flag = 'Y'
6992 and paf.assignment_id =
6993 (select max(pafm.assignment_id) -- This select ensures that
6994 from per_assignments_f pafm -- for rehires only the last
6995 where pafm.person_id = ppf.person_id -- assignment is used
6996 and pafm.primary_flag = 'Y'
6997 and pafm.business_group_id = p_business_group_id)
6998 -- and ppf.start_date between
6999 -- paf.effective_start_date and
7000 -- paf.effective_end_date
7001 and paf.effective_start_date <= l_year_end
7002 and paf.effective_end_date >= l_year_start
7003 and paf.effective_start_date =
7004 (select max(paf_max.effective_start_date)
7005 from per_assignments_f paf_max
7006 where paf_max.assignment_id = paf.assignment_id
7007 and paf_max.primary_flag = 'Y'
7008 and paf_max.effective_start_date <= l_year_end
7009 and paf_max.effective_end_date >= l_year_start
7010 and paf_max.business_group_id = p_business_group_id)
7011 and (paf.employment_category is null OR
7012 substr(paf.employment_category,1,2) not in ('FR','PR','PT'))
7013 and paf.person_id = ppf.person_id
7014 and ppf.effective_start_date <= l_year_end
7015 and ppf.effective_end_date >= l_year_start
7016 and ppf.effective_start_date =
7017 (select max(ppf_max.effective_start_date) -- The last person
7018 from per_people_f ppf_max -- record in the year
7019 where ppf_max.person_id = ppf.person_id
7020 and ppf_max.effective_start_date <= l_year_end
7021 and ppf_max.effective_end_date >= l_year_start
7022 and ppf_max.business_group_id = p_business_group_id
7023 and person_type_exists(ppf_max.person_type_id) is not null)
7024 and person_type_exists(ppf.person_type_id) is not null
7025 and ppf.business_group_id = p_business_group_id
7026 and paf.location_id = hl1.location_id
7027 and hl1.region_1 = hl2.lookup_code
7028 and hl2.lookup_type = 'CA_PROVINCE'
7029 and pert.request_id = p_request_id
7030 and hl2.meaning = pert.segment2
7031 and pert.context = 'FORM14'
7032 and pert.segment1 = 'PROVINCE'
7033 and decode (desig, 0, 'Y',
7034 1, per_information5,
7035 2, per_information6,
7036 3, per_information7) = 'Y'
7037 and
7038 (
7039 (
7040 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
7041 hsck.segment6 is not null and
7042 hsck.segment6 = v_naic_code
7043 )
7044 OR
7045 (
7046 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
7047 hsck.segment6 is null and
7048 hsck.segment1 in
7049 (select segment3
7050 from per_ca_ee_report_lines
7051 where request_id = p_request_id
7052 and context = 'FORM13'
7053 and segment1 = 'NAIC'
7054 and segment2 = v_naic_code)
7055 )
7056 )
7057 )
7058 group by province,meaning,employment_category,sex
7059 order by province,meaning,employment_category,sex;
7060
7061 v_count number(10);
7062 v_meaning hr_lookups.meaning%TYPE;
7063 v_employment_category per_assignments_f.employment_category%TYPE;
7064 v_sex per_people_f.sex%TYPE;
7065 v_province hr_locations.region_1%TYPE;
7066 prev_meaning hr_lookups.meaning%TYPE := 'test';
7067 prev_employment_category per_assignments_f.employment_category%TYPE := 'test';
7068 prev_sex per_people_f.sex%TYPE := 'test';
7069 prev_naic_code hr_lookups.lookup_code%TYPE;
7070
7071 cursor cur_meaning is
7072 select meaning
7073 from hr_lookups
7074 where upper(ltrim(rtrim(lookup_type)))='CA_PROVINCE'
7075 and upper(ltrim(rtrim(lookup_code)))=upper(ltrim(rtrim(v_province)));
7076
7077 v_province_name hr_lookups.meaning%TYPE;
7078 prev_province_name hr_lookups.meaning%TYPE;
7079
7080 cursor cur_eeog is
7081 select meaning
7082 from hr_lookups
7083 where lookup_type='EEOG';
7084
7085 cursor cur_notfound(p_emp_cat number) is
7086 select
7087 segment2,
7088 v_meaning,
7089 decode(p_emp_cat,1,'FR',2,'PR',3,'PT') emp_category
7090 from
7091 per_ca_ee_report_lines where
7092 request_id=p_request_id and
7093 context='FORM14' and
7094 segment1='PROVINCE' and
7095 segment3 <> '0'
7096 minus
7097 select
7098 segment2,
7099 segment3,
7100 segment4
7101 from
7102 per_ca_ee_report_lines
7103 where
7107 segment21 = v_naic_code;
7104 request_id=p_request_id and
7105 context='FORM5' and
7106 segment1='PROVINCE'and
7108
7109 cursor cur_count_national is
7110 select
7111 segment3,
7112 segment4,
7113 sum(to_number(segment5)) segment5,
7114 sum(to_number(segment6)) segment6,
7115 sum(to_number(segment7)) segment7,
7116 sum(to_number(segment8)) segment8,
7117 sum(to_number(segment9)) segment9,
7118 sum(to_number(segment10)) segment10,
7119 sum(to_number(segment11)) segment11,
7120 sum(to_number(segment12)) segment12,
7121 sum(to_number(segment13)) segment13,
7122 sum(to_number(segment14)) segment14,
7123 sum(to_number(segment15)) segment15,
7124 sum(to_number(segment16)) segment16
7125 from
7126 per_ca_ee_report_lines
7127 where
7128 request_id = p_request_id and
7129 context = 'FORM5' and
7130 segment1 = 'PROVINCE' and
7131 segment21 = v_naic_code
7132 group by segment3,segment4;
7133
7134 cursor cur_total_promotions(desig number) is
7135 select
7136 sum(promotion_total) promotion_total,
7137 sex sex,
7138 employment_category employment_category,
7139 province province
7140 from
7141 (
7142 select
7143 employee_promotions(paf.assignment_id,
7144 paf.person_id,
7145 p_business_group_id,
7146 l_year_start,
7147 l_year_end,
7148 'N') promotion_total,
7149 ppf.sex sex,
7150 substr(paf.employment_category,1,2) employment_category,
7151 hl1.region_1 province
7152 from
7153 per_assignments_f paf,
7154 per_people_f ppf,
7155 hr_locations hl1,
7156 per_ca_ee_report_lines pert,
7157 hr_lookups hl2,
7158 hr_soft_coding_keyflex hsck
7159 where
7160 job_exists(paf.job_id) is not null
7161 and paf.primary_flag = 'Y'
7162 and paf.assignment_id =
7163 (select max(pafm.assignment_id) -- This select ensures that
7164 from per_assignments_f pafm -- for rehires only the last
7165 where pafm.person_id = ppf.person_id -- assignment is used
7166 and pafm.primary_flag = 'Y'
7167 and pafm.business_group_id = p_business_group_id)
7168 -- ppf.start_date between
7169 -- paf.effective_start_date and
7170 -- paf.effective_end_date and
7171 and paf.effective_start_date <= l_year_end
7172 and paf.effective_end_date >= l_year_start
7173 and paf.effective_start_date =
7174 (select max(paf_max.effective_start_date)
7175 from per_assignments_f paf_max
7176 where paf_max.assignment_id = paf.assignment_id
7177 and paf_max.primary_flag = 'Y'
7178 and paf_max.effective_start_date <= l_year_end
7179 and paf_max.effective_end_date >= l_year_start
7180 and paf_max.business_group_id = p_business_group_id)
7181 and paf.employment_category is not null
7182 and substr(paf.employment_category,1,2) in ('FR','PR','PT')
7183 and paf.person_id=ppf.person_id
7184 and ppf.effective_start_date <= l_year_end
7185 and ppf.effective_end_date >= l_year_start
7186 and ppf.effective_start_date =
7187 (select max(ppf_max.effective_start_date) -- The last person
7188 from per_people_f ppf_max -- record in the year
7189 where ppf_max.person_id = ppf.person_id
7190 and ppf_max.effective_start_date <= l_year_end
7191 and ppf_max.effective_end_date >= l_year_start
7192 and ppf_max.business_group_id = p_business_group_id
7193 and person_type_exists(ppf_max.person_type_id) is not null)
7194 and person_type_exists(ppf.person_type_id) is not null
7195 and ppf.business_group_id=p_business_group_id
7196 and paf.location_id=hl1.location_id
7197 and hl1.region_1=hl2.lookup_code
7198 and hl2.lookup_type='CA_PROVINCE'
7199 and pert.request_id=p_request_id
7200 and hl2.meaning=pert.segment2
7201 and pert.context='FORM14'
7202 and pert.segment1='PROVINCE'
7203 and decode (desig, 0, 'Y',
7204 1, per_information5,
7205 2, per_information6,
7206 3, per_information7) = 'Y'
7207 and (
7208 (
7209 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
7210 hsck.segment6 is not null and
7211 hsck.segment6 = v_naic_code
7212 )
7213 OR
7214 (
7215 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
7216 hsck.segment6 is null and
7217 hsck.segment1 in (select segment3
7218 from per_ca_ee_report_lines
7219 where request_id = p_request_id and
7220 context = 'FORM13' and
7221 segment1 = 'NAIC' and
7222 segment2 = v_naic_code)
7223 )
7224 )
7225 union all
7226 select
7227 employee_promotions(paf.assignment_id,
7228 paf.person_id,
7229 p_business_group_id,
7230 l_year_start,
7234 'FR' employment_category,
7231 l_year_end,
7232 'N') promotion_total,
7233 ppf.sex sex,
7235 hl1.region_1 province
7236 from
7237 per_assignments_f paf,
7238 per_people_f ppf,
7239 hr_locations hl1,
7240 per_ca_ee_report_lines pert,
7241 hr_lookups hl2,
7242 hr_soft_coding_keyflex hsck
7243 where
7244 job_exists(paf.job_id) is not null
7245 and paf.primary_flag = 'Y'
7246 and paf.assignment_id =
7247 (select max(pafm.assignment_id) -- This select ensures that
7248 from per_assignments_f pafm -- for rehires only the last
7249 where pafm.person_id = ppf.person_id -- assignment is used
7250 and pafm.primary_flag = 'Y'
7251 and pafm.business_group_id = p_business_group_id)
7252 -- ppf.start_date between
7253 -- paf.effective_start_date and
7254 -- paf.effective_end_date and
7255 and paf.effective_start_date <= l_year_end
7256 and paf.effective_end_date >= l_year_start
7257 and paf.effective_start_date =
7258 (select max(paf_max.effective_start_date)
7259 from per_assignments_f paf_max
7260 where paf_max.assignment_id = paf.assignment_id
7261 and paf_max.primary_flag = 'Y'
7262 and paf_max.effective_start_date <= l_year_end
7263 and paf_max.effective_end_date >= l_year_start
7264 and paf_max.business_group_id = p_business_group_id)
7265 and (paf.employment_category is null OR
7266 substr(paf.employment_category,1,2) not in ('FR','PR','PT'))
7267 and paf.person_id=ppf.person_id
7268 and ppf.effective_start_date <= l_year_end
7269 and ppf.effective_end_date >= l_year_start
7270 and ppf.effective_start_date =
7271 (select max(ppf_max.effective_start_date) -- The last person
7272 from per_people_f ppf_max -- record in the year
7273 where ppf_max.person_id = ppf.person_id
7274 and ppf_max.effective_start_date <= l_year_end
7275 and ppf_max.effective_end_date >= l_year_start
7276 and ppf_max.business_group_id = p_business_group_id
7277 and person_type_exists(ppf_max.person_type_id) is not null)
7278 and person_type_exists(ppf.person_type_id) is not null
7279 and ppf.business_group_id=p_business_group_id
7280 and paf.location_id=hl1.location_id
7281 and hl1.region_1=hl2.lookup_code
7282 and hl2.lookup_type='CA_PROVINCE'
7283 and pert.request_id=p_request_id
7284 and hl2.meaning=pert.segment2
7285 and pert.context='FORM14'
7286 and pert.segment1='PROVINCE'
7287 and decode (desig, 0, 'Y',
7288 1, per_information5,
7289 2, per_information6,
7290 3, per_information7) = 'Y'
7291 and
7292 (
7293 (
7294 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
7295 hsck.segment6 is not null and
7296 hsck.segment6 = v_naic_code
7297 )
7298 OR
7299 (
7300 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
7301 hsck.segment6 is null and
7302 hsck.segment1 in
7303 (select segment3
7304 from per_ca_ee_report_lines
7305 where request_id = p_request_id
7306 and context = 'FORM13'
7307 and segment1 = 'NAIC'
7308 and segment2 = v_naic_code)
7309 )
7310 )
7311 )
7312 group by province,employment_category,sex
7313 order by province,employment_category,sex;
7314
7315 cursor cur_count_national_promotions is
7316 select
7317 segment3,
7318 sum(to_number(segment4)) segment4,
7319 sum(to_number(segment5)) segment5,
7320 sum(to_number(segment6)) segment6,
7321 sum(to_number(segment7)) segment7,
7322 sum(to_number(segment8)) segment8,
7323 sum(to_number(segment9)) segment9,
7324 sum(to_number(segment10)) segment10,
7325 sum(to_number(segment11)) segment11,
7326 sum(to_number(segment12)) segment12,
7327 sum(to_number(segment13)) segment13,
7328 sum(to_number(segment14)) segment14,
7329 sum(to_number(segment15)) segment15
7330 from
7331 per_ca_ee_report_lines
7332 where
7333 request_id = p_request_id and
7334 context = 'FORM5P' and
7335 segment1 = 'PROVINCE' and
7336 segment21 = v_naic_code
7337 group by segment3;
7338
7339 cursor cur_notfound_promotions(emp_cat number) is
7340 select
7341 segment2,
7342 decode(emp_cat,1,'FR','2','PR',3,'PT') emp_category
7343 from
7344 per_ca_ee_report_lines
7345 where
7346 request_id = p_request_id and
7347 segment3 <> '0' and
7348 context = 'FORM14'
7349 minus
7350 select
7351 segment2,
7352 segment3
7353 from
7354 per_ca_ee_report_lines
7355 where
7356 request_id = p_request_id and
7357 context = 'FORM5P' and
7358 segment1 = 'PROVINCE' ;
7359
7360 begin
7361
7362 /* Caching data from per_jobs and per_person_types tables */
7363
7364 open cur_jobs;
7365 fetch cur_jobs bulk collect into
7366 v_job_id_temp,
7367 v_job_temp;
7368
7369 close cur_jobs;
7370
7374 v_job(v_job_id_temp(i)) := v_job_temp(i);
7371 if v_job_id_temp.count > 0 then
7372 for i in v_job_id_temp.first..v_job_id_temp.last LOOP
7373 v_job_id(v_job_id_temp(i)) := v_job_id_temp(i);
7375 end loop;
7376 end if;
7377
7378 open cur_person_types;
7379 fetch cur_person_types bulk collect into
7380 v_person_type_temp;
7381
7382 close cur_person_types;
7383
7384 if v_person_type_temp.count > 0 then
7385 for i in v_person_type_temp.first..v_person_type_temp.last LOOP
7386 v_person_type(v_person_type_temp(i)) := v_person_type_temp(i);
7387 end loop;
7388 end if;
7389
7390 for naic in cur_naic loop
7391
7392 v_naic_code := naic.naic_code;
7393
7394 hr_utility.trace('Form5: v_naic = ' || v_naic_code );
7395
7396 for i in 0..3 loop
7397
7398 for j in cur_promoted_total(i)
7399 loop
7400 v_count := j.employee_total;
7401 v_meaning := j.meaning;
7402 v_employment_category := j.employment_category;
7403 v_sex := j.sex;
7404 v_province := j.province;
7405
7406 open cur_meaning;
7407 fetch cur_meaning into v_province_name;
7408 close cur_meaning;
7409
7410 if v_count <> 0 then -- Only employees who have been promoted
7411
7412 if i = 0 then
7413
7414 if ((ltrim(rtrim(v_province_name))
7415 <>ltrim(rtrim(prev_province_name))) or
7416 (ltrim(rtrim(prev_meaning)) <> ltrim(rtrim(v_meaning))) or
7417 (ltrim(rtrim(prev_naic_code)) <> ltrim(rtrim(v_naic_code))) or
7418 (ltrim(rtrim(prev_employment_category)) <>
7419 ltrim(rtrim(v_employment_category)))) then
7420
7421 per_ca_ee_extract_pkg.k := per_ca_ee_extract_pkg.k + 1;
7422
7423 insert into per_ca_ee_report_lines
7424 (request_id,
7425 line_number,
7426 context,
7427 segment1,
7428 segment2,
7429 segment3,
7430 segment4,
7431 segment5,
7432 segment6,
7433 segment7,
7434 segment8,
7435 segment9,
7436 segment10,
7437 segment11,
7438 segment12,
7439 segment13,
7440 segment14,
7441 segment15,
7442 segment16,
7443 segment21) values
7444 ( p_request_id,
7445 per_ca_ee_extract_pkg.k,
7446 'FORM5',
7447 'PROVINCE',
7448 v_province_name,
7449 v_meaning,
7450 v_employment_category,
7451 nvl(v_count,0),
7452 decode(v_sex,'F',v_count,0),
7453 decode(v_sex,'M',v_count,0),
7454 '0',
7455 '0',
7456 '0',
7457 '0',
7458 '0',
7459 '0',
7460 '0',
7461 '0',
7462 '0',
7463 v_naic_code);
7464 else
7465
7466 if prev_province_name = v_province_name and
7467 prev_meaning = v_meaning and
7468 prev_naic_code = v_naic_code and
7469 prev_employment_category = v_employment_category and
7470 prev_sex <> v_sex then
7471
7472 if v_sex = 'M' then
7473
7474 update per_ca_ee_report_lines set
7475 segment7=nvl(v_count,0),
7476 segment5=segment5 + nvl(v_count,0)
7477 where request_id=p_request_id and
7478 line_number = per_ca_ee_extract_pkg.k and
7479 context='FORM5' and
7480 segment1='PROVINCE' and
7481 segment2=v_province_name and
7482 segment3=v_meaning and
7483 segment4=v_employment_category and
7484 segment21=v_naic_code;
7485
7486 elsif v_sex = 'F' then
7487
7488 update per_ca_ee_report_lines set
7489 segment6=nvl(v_count,0),
7490 segment5=segment5 + nvl(v_count,0)
7491 where request_id=p_request_id and
7492 line_number = per_ca_ee_extract_pkg.k and
7493 context='FORM5' and
7494 segment1='PROVINCE' and
7495 segment2=v_province_name and
7496 segment3=v_meaning and
7497 segment4=v_employment_category and
7498 segment21=v_naic_code;
7499
7500 end if;
7501
7502 end if;
7503 end if;
7504
7505 prev_meaning := v_meaning;
7506 prev_employment_category := v_employment_category;
7507 prev_sex := v_sex;
7511 elsif i = 1 then
7508 prev_province_name := v_province_name;
7509 prev_naic_code := v_naic_code;
7510
7512
7513 if v_sex = 'M' then
7514
7515 update per_ca_ee_report_lines set
7516 segment8 = nvl(segment8,0) + nvl(v_count,0),
7517 segment10 = nvl(v_count,0)
7518 where
7519 request_id = p_request_id and
7520 context = 'FORM5' and
7521 segment1 = 'PROVINCE' and
7522 segment2 = v_province_name and
7523 segment3 = v_meaning and
7524 segment4 = v_employment_category and
7525 segment21 = v_naic_code;
7526
7527 elsif v_sex = 'F' then
7528
7529 update per_ca_ee_report_lines set
7530 segment8 = nvl(segment8,0) + nvl(v_count,0),
7531 segment9 = nvl(v_count,0)
7532 where
7533 request_id = p_request_id and
7534 context = 'FORM5' and
7535 segment1 = 'PROVINCE' and
7536 segment2 = v_province_name and
7537 segment3 = v_meaning and
7538 segment4 = v_employment_category and
7539 segment21 = v_naic_code;
7540
7541 end if;
7542
7543 elsif i = 2 then
7544
7545 if v_sex = 'M' then
7546
7547 update per_ca_ee_report_lines set
7548 segment11 = nvl(segment11,0) + nvl(v_count,0),
7549 segment13 = nvl(v_count,0)
7550 where
7551 request_id = p_request_id and
7552 context = 'FORM5' and
7553 segment1 = 'PROVINCE' and
7554 segment2 = v_province_name and
7555 segment3 = v_meaning and
7556 segment4 = v_employment_category and
7557 segment21 = v_naic_code;
7558
7559 elsif v_sex = 'F' then
7560
7561 update per_ca_ee_report_lines set
7562 segment11 = nvl(segment11,0) + nvl(v_count,0),
7563 segment12 = nvl(v_count,0)
7564 where
7565 request_id = p_request_id and
7566 context = 'FORM5' and
7567 segment1 = 'PROVINCE' and
7568 segment2 = v_province_name and
7569 segment3 = v_meaning and
7570 segment4 = v_employment_category and
7571 segment21 = v_naic_code;
7572
7573 end if;
7574
7575 elsif i = 3 then
7576
7577 if v_sex = 'M' then
7578
7579 update per_ca_ee_report_lines set
7580 segment14 = nvl(segment14,0) + nvl(v_count,0),
7581 segment16 = nvl(v_count,0)
7582 where
7583 request_id = p_request_id and
7584 context = 'FORM5' and
7585 segment1 = 'PROVINCE' and
7586 segment2 = v_province_name and
7587 segment3 = v_meaning and
7588 segment4 = v_employment_category and
7589 segment21 = v_naic_code;
7590
7591 elsif v_sex = 'F' then
7592
7593 update per_ca_ee_report_lines set
7594 segment14 = nvl(segment14,0) + nvl(v_count,0),
7595 segment15 = nvl(v_count,0)
7596 where
7597 request_id = p_request_id and
7598 context = 'FORM5' and
7599 segment1 = 'PROVINCE' and
7600 segment2 = v_province_name and
7601 segment3 = v_meaning and
7602 segment4 = v_employment_category and
7603 segment21 = v_naic_code;
7604
7605 end if;
7606 end if;
7607 end if;
7608 end loop; -- End loop cur_promoted_total
7609 end loop; -- End loop Designated Group
7610
7611 for i in cur_eeog loop
7612
7613 v_meaning := i.meaning;
7614
7615 hr_utility.trace('Form5: cur_eeog: v_eeog' || v_meaning);
7616
7617 for emp_cat in 1..3 loop
7618
7619 for x in cur_notfound(emp_cat) loop
7620
7621 per_ca_ee_extract_pkg.k := per_ca_ee_extract_pkg.k + 1;
7622
7623 insert into per_ca_ee_report_lines
7624 (request_id,
7625 line_number,
7626 context,
7627 segment1,
7628 segment2,
7629 segment3,
7630 segment4,
7631 segment5,
7632 segment6,
7633 segment7,
7634 segment8,
7635 segment9,
7636 segment10,
7637 segment11,
7638 segment12,
7639 segment13,
7640 segment14,
7641 segment15,
7642 segment16,
7643 segment21) values
7644 ( p_request_id,
7645 per_ca_ee_extract_pkg.k,
7646 'FORM5',
7647 'PROVINCE',
7648 x.segment2,
7649 v_meaning,
7650 x.emp_category,
7651 0,
7652 0,
7653 0,
7657 0,
7654 0,
7655 0,
7656 0,
7658 0,
7659 0,
7660 0,
7661 0,
7662 0,
7663 v_naic_code);
7664
7665 end loop; -- End loop cur_notfound
7666
7667 end loop; -- End loop emp_cat
7668
7669 end loop; -- End loop cur_eeog
7670
7671 prev_province_name := 'test';
7672 prev_employment_category := 'te';
7673 prev_naic_code := 'te';
7674
7675 for i in 0..3 loop
7676
7677 for j in cur_total_promotions(i) loop
7678
7679 hr_utility.trace('Form5P: cur_total_promotions');
7680
7681 v_count := j.promotion_total;
7682 v_employment_category := j.employment_category;
7683 v_sex := j.sex;
7684 v_province := j.province;
7685
7686 open cur_meaning;
7687 fetch cur_meaning into v_province_name;
7688 close cur_meaning;
7689
7690 if v_count <> 0 then -- Only process when promotions exist
7691
7692 if i = 0 then
7693
7694 hr_utility.trace('Form5P: prev_province_name: ' || prev_province_name);
7695 hr_utility.trace('Form5P: v_province_name: ' || v_province_name);
7696 hr_utility.trace('Form5P: prev_naic_code: ' || prev_naic_code);
7697 hr_utility.trace('Form5P: v_naic_code: ' || v_naic_code);
7698 hr_utility.trace('Form5P: prev_emp_category: ' || prev_employment_category);
7699 hr_utility.trace('Form5P: v_emp_category: ' || v_employment_category);
7700
7701 if ((ltrim(rtrim(v_province_name))
7702 <>ltrim(rtrim(prev_province_name))) or
7703 (ltrim(rtrim(prev_naic_code)) <> ltrim(rtrim(v_naic_code))) or
7704 (ltrim(rtrim(prev_employment_category)) <>
7705 ltrim(rtrim(v_employment_category)))) then
7706
7707 hr_utility.trace('Form5P: cur_total_promotions : Inside If');
7708 per_ca_ee_extract_pkg.k := per_ca_ee_extract_pkg.k + 1;
7709
7710 insert into per_ca_ee_report_lines
7711 (request_id,
7712 line_number,
7713 context,
7714 segment1,
7715 segment2,
7716 segment3,
7717 segment4,
7718 segment5,
7719 segment6,
7720 segment7,
7721 segment8,
7722 segment9,
7723 segment10,
7724 segment11,
7725 segment12,
7726 segment13,
7727 segment14,
7728 segment15,
7729 segment21) values
7730 (p_request_id,
7731 per_ca_ee_extract_pkg.k,
7732 'FORM5P',
7733 'PROVINCE',
7734 v_province_name,
7735 v_employment_category,
7736 nvl(v_count,0),
7737 decode(v_sex,'M',v_count,0),
7738 decode(v_sex,'F',v_count,0),
7739 '0',
7740 '0',
7741 '0',
7742 '0',
7743 '0',
7744 '0',
7745 '0',
7746 '0',
7747 '0',
7748 v_naic_code);
7749
7750 else
7751
7752 if prev_province_name = v_province_name and
7753 prev_naic_code = v_naic_code and
7754 prev_employment_category = v_employment_category and
7755 prev_sex <> v_sex then
7756
7757 if v_sex = 'M' then
7758
7759 update per_ca_ee_report_lines set
7760 segment5=nvl(v_count,0),
7761 segment4=segment4 + nvl(v_count,0)
7762 where request_id=p_request_id and
7763 line_number = per_ca_ee_extract_pkg.k and
7764 context='FORM5P' and
7765 segment1='PROVINCE' and
7766 segment2=v_province_name and
7767 segment3=v_employment_category and
7768 segment21=v_naic_code;
7769
7770 elsif v_sex = 'F' then
7771
7772 update per_ca_ee_report_lines set
7773 segment6=nvl(v_count,0),
7774 segment4=segment4 + nvl(v_count,0)
7775 where request_id=p_request_id and
7776 line_number = per_ca_ee_extract_pkg.k and
7777 context='FORM5P' and
7778 segment1='PROVINCE' and
7779 segment2=v_province_name and
7780 segment3=v_employment_category and
7781 segment21=v_naic_code;
7782
7783 end if;
7784
7785 end if;
7786
7787 end if;
7788
7789 prev_province_name := v_province_name;
7790 prev_naic_code := v_naic_code;
7791 prev_employment_category := v_employment_category;
7792 prev_sex := v_sex;
7793
7794 elsif i = 1 then
7795
7796
7797 if v_sex = 'M' then
7798
7799 update per_ca_ee_report_lines set
7800 segment7 = nvl(segment7,0) + nvl(v_count,0),
7804 context = 'FORM5P' and
7801 segment8 = nvl(v_count,0)
7802 where
7803 request_id = p_request_id and
7805 segment1 = 'PROVINCE' and
7806 segment2 = v_province_name and
7807 segment3 = v_employment_category and
7808 segment21 = v_naic_code;
7809
7810 elsif v_sex = 'F' then
7811
7812 update per_ca_ee_report_lines set
7813 segment7 = nvl(segment7,0) + nvl(v_count,0),
7814 segment9 = nvl(v_count,0)
7815 where
7816 request_id = p_request_id and
7817 context = 'FORM5P' and
7818 segment1 = 'PROVINCE' and
7819 segment2 = v_province_name and
7820 segment3 = v_employment_category and
7821 segment21 = v_naic_code;
7822
7823 end if;
7824
7825 elsif i = 2 then
7826
7827 if v_sex = 'M' then
7828
7829 update per_ca_ee_report_lines set
7830 segment10 = nvl(segment10,0) + nvl(v_count,0),
7831 segment11 = nvl(v_count,0)
7832 where
7833 request_id = p_request_id and
7834 context = 'FORM5P' and
7835 segment1 = 'PROVINCE' and
7836 segment2 = v_province_name and
7837 segment3 = v_employment_category and
7838 segment21 = v_naic_code;
7839
7840 elsif v_sex = 'F' then
7841
7842 update per_ca_ee_report_lines set
7843 segment10 = nvl(segment10,0) + nvl(v_count,0),
7844 segment12 = nvl(v_count,0)
7845 where
7846 request_id = p_request_id and
7847 context = 'FORM5P' and
7848 segment1 = 'PROVINCE' and
7849 segment2 = v_province_name and
7850 segment3 = v_employment_category and
7851 segment21 = v_naic_code;
7852
7853 end if;
7854
7855 elsif i = 3 then
7856
7857 if v_sex = 'M' then
7858
7859 update per_ca_ee_report_lines set
7860 segment13 = nvl(segment13,0) + nvl(v_count,0),
7861 segment14 = nvl(v_count,0)
7862 where
7863 request_id = p_request_id and
7864 context = 'FORM5P' and
7865 segment1 = 'PROVINCE' and
7866 segment2 = v_province_name and
7867 segment3 = v_employment_category and
7868 segment21 = v_naic_code;
7869
7870 elsif v_sex = 'F' then
7871
7872 update per_ca_ee_report_lines set
7873 segment13 = nvl(segment13,0) + nvl(v_count,0),
7874 segment15 = nvl(v_count,0)
7875 where
7876 request_id = p_request_id and
7877 context = 'FORM5P' and
7878 segment1 = 'PROVINCE' and
7879 segment2 = v_province_name and
7880 segment3 = v_employment_category and
7881 segment21 = v_naic_code;
7882
7883 end if;
7884
7885 end if;
7886 end if;
7887 end loop; -- End loop cur_total_promotions
7888 end loop; -- End loop for designated group members.
7889
7890 for i in 1..3 loop
7891 for j in cur_notfound_promotions(i) loop
7892
7893 insert into per_ca_ee_report_lines
7894 (request_id,
7895 line_number,
7896 context,
7897 segment1,
7898 segment2,
7899 segment3,
7900 segment4,
7901 segment5,
7902 segment6,
7903 segment7,
7904 segment8,
7905 segment9,
7906 segment10,
7907 segment11,
7908 segment12,
7909 segment13,
7910 segment14,
7911 segment15,
7912 segment21) values
7913 (p_request_id,
7914 per_ca_ee_extract_pkg.k,
7915 'FORM5P',
7916 'PROVINCE',
7917 j.segment2,
7918 j.emp_category,
7919 '0',
7920 '0',
7921 '0',
7922 '0',
7923 '0',
7924 '0',
7925 '0',
7926 '0',
7927 '0',
7928 '0',
7929 '0',
7930 '0',
7931 v_naic_code);
7932
7933 end loop;
7934 end loop; -- End loop for designated group members.
7935
7936 for i in cur_count_national_promotions loop
7937
7938 insert into per_ca_ee_report_lines
7939 (request_id,
7940 line_number,
7941 context,
7942 segment1,
7943 segment2,
7944 segment3,
7945 segment4,
7946 segment5,
7947 segment6,
7948 segment7,
7949 segment8,
7950 segment9,
7951 segment10,
7952 segment11,
7953 segment12,
7954 segment13,
7955 segment14,
7956 segment21) values
7957 (p_request_id,
7958 per_ca_ee_extract_pkg.k,
7959 'FORM5P',
7960 'NATIONAL',
7961 i.segment3,
7962 i.segment4,
7963 i.segment5,
7964 i.segment6,
7965 i.segment7,
7966 i.segment8,
7967 i.segment9,
7968 i.segment10,
7969 i.segment11,
7970 i.segment12,
7971 i.segment13,
7972 i.segment14,
7973 i.segment15,
7974 v_naic_code);
7975
7976 end loop;
7977
7978 for count_national in cur_count_national loop
7979
7980 hr_utility.trace('Form5: cur_count_national. ');
7981
7982 insert into per_ca_ee_report_lines
7983 (request_id,
7984 line_number,
7985 context,
7986 segment1,
7987 segment2,
7988 segment3,
7989 segment4,
7990 segment5,
7991 segment6,
7992 segment7,
7993 segment8,
7994 segment9,
7995 segment10,
7996 segment11,
7997 segment12,
7998 segment13,
7999 segment14,
8000 segment15,
8001 segment21) values
8002 ( p_request_id,
8003 per_ca_ee_extract_pkg.k,
8004 'FORM5',
8005 'NATIONAL',
8006 count_national.segment3,
8007 count_national.segment4,
8008 count_national.segment5,
8009 count_national.segment6,
8010 count_national.segment7,
8011 count_national.segment8,
8012 count_national.segment9,
8013 count_national.segment10,
8014 count_national.segment11,
8015 count_national.segment12,
8016 count_national.segment13,
8017 count_national.segment14,
8018 count_national.segment15,
8019 count_national.segment16,
8020 v_naic_code);
8021
8022 end loop; -- End loop cur_count_national
8023
8024 prev_naic_code := v_naic_code;
8025
8026 end loop; -- End loop cur_naic
8027
8028 return 1;
8029
8030 end;
8031 end form5;
8032
8033 function form6(p_business_group_id in number,
8034 p_request_id in number,
8035 p_year in varchar2,
8036 p_date_tmp_emp in date) return number is
8037
8038 l_year_start date;
8039 l_year_end date;
8040
8041 begin
8042
8043 l_year_start := trunc(to_date(p_year,'YYYY'),'Y');
8044 l_year_end := add_months(trunc(to_date(p_year,'YYYY'),'Y'), 12) -1;
8045
8046 declare
8047
8048 cursor cur_naic is
8049 select
8050 pert.segment4 naic_code
8051 from
8052 per_ca_ee_report_lines pert
8053 where
8054 pert.request_id = p_request_id and
8055 pert.context = 'FORM12';
8056
8057 v_naic_code hr_lookups.lookup_code%TYPE;
8058
8059 cursor cur_terminated_total is
8060 select
8061 count(distinct count_total) count_total,
8062 meaning meaning,
8063 sex sex,
8064 employment_category employment_category,
8065 region_1 region_1
8066 from
8067 (
8068 select
8069 paf.person_id count_total,
8070 hl.meaning meaning,
8071 ppf.sex sex,
8072 substr(paf.employment_category,1,2) employment_category,
8073 hl1.region_1 region_1
8074 from
8075 hr_lookups hl,
8076 per_jobs pj,
8077 per_assignments_f paf,
8078 per_people_f ppf,
8079 per_person_types ppt,
8080 per_periods_of_service ppos,
8081 hr_locations hl1,
8082 hr_soft_coding_keyflex hsck
8083 where
8084 hl.lookup_type='EEOG' and
8085 upper(ltrim(rtrim(hl.lookup_code)))
8086 = upper(ltrim(rtrim(pj.job_information1))) and
8087 upper(ltrim(rtrim(pj.job_information_category))) = 'CA' and
8088 pj.job_id=paf.job_id and
8089 paf.primary_flag = 'Y' and
8090 paf.employment_category is not null and
8091 substr(paf.employment_category,1,2) in ('FR','PR','PT') and
8092 --decode(paf.employment_category,'PT',p_date_tmp_emp,l_year_end) between
8093 ppos.actual_termination_date between
8094 paf.effective_start_date and
8095 paf.effective_end_date and
8096 paf.location_id=hl1.location_id and
8097 paf.person_id=ppf.person_id and
8098 --decode(paf.employment_category,'PT',p_date_tmp_emp,l_year_end) between
8099 ppos.actual_termination_date between
8100 ppf.effective_start_date and
8101 ppf.effective_end_date and
8102 ppf.person_type_id = ppt.person_type_id and
8103 --upper(ltrim(rtrim(ppt.system_person_type)))='EX_EMP' and
8104 ppf.business_group_id=p_business_group_id and
8105 ppf.person_id=ppos.person_id and
8106 ppos.actual_termination_date is not null and
8107 ppos.actual_termination_date >= l_year_start and
8111 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
8108 ppos.actual_termination_date <= l_year_end and
8109 (
8110 (
8112 hsck.segment6 is not null and
8113 hsck.segment6 = v_naic_code
8114 )
8115 OR
8116 (
8117 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
8118 hsck.segment6 is null and
8119 hsck.segment1 in (select segment3
8120 from per_ca_ee_report_lines
8121 where request_id = p_request_id and
8122 context = 'FORM13' and
8123 segment1 = 'NAIC' and
8124 segment2 = v_naic_code)
8125 )
8126 ) and
8127 exists
8128 (
8129 select 'X'
8130 from per_pay_proposals_v2 pppv
8131 where
8132 pppv.assignment_id = paf.assignment_id and
8133 pppv.approved = 'Y' and
8134 pppv.change_date <= l_year_end
8135 )
8136 union all
8137 select
8138 paf.person_id count_total,
8139 hl.meaning meaning,
8140 ppf.sex sex,
8141 'FR' employment_category,
8142 hl1.region_1 region_1
8143 from
8144 hr_lookups hl,
8145 per_jobs pj,
8146 per_assignments_f paf,
8147 per_people_f ppf,
8148 per_person_types ppt,
8149 per_periods_of_service ppos,
8150 hr_locations hl1,
8151 hr_soft_coding_keyflex hsck
8152 where
8153 hl.lookup_type='EEOG' and
8154 upper(ltrim(rtrim(hl.lookup_code)))
8155 = upper(ltrim(rtrim(pj.job_information1))) and
8156 upper(ltrim(rtrim(pj.job_information_category))) = 'CA' and
8157 pj.job_id=paf.job_id and
8158 paf.primary_flag = 'Y' and
8159 --l_year_end between
8160 ppos.actual_termination_date between
8161 paf.effective_start_date and
8162 paf.effective_end_date and
8163 (paf.employment_category is null OR
8164 substr(paf.employment_category,1,2) in ('FR','PR','PT')) and
8165 paf.location_id=hl1.location_id and
8166 paf.person_id=ppf.person_id and
8167 --l_year_end between
8168 ppos.actual_termination_date between
8169 ppf.effective_start_date and
8170 ppf.effective_end_date and
8171 ppf.person_type_id = ppt.person_type_id and
8172 --upper(ltrim(rtrim(ppt.system_person_type)))='EX_EMP' and
8173 ppf.business_group_id=p_business_group_id and
8174 ppf.person_id=ppos.person_id and
8175 ppos.actual_termination_date is not null and
8176 ppos.actual_termination_date >= l_year_start and
8177 ppos.actual_termination_date <= l_year_end and
8178 (
8179 (
8180 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
8181 hsck.segment6 is not null and
8182 hsck.segment6 = v_naic_code
8183 )
8184 OR
8185 (
8186 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
8187 hsck.segment6 is null and
8188 hsck.segment1 in (select segment3
8189 from per_ca_ee_report_lines
8190 where request_id = p_request_id and
8191 context = 'FORM13' and
8192 segment1 = 'NAIC' and
8193 segment2 = v_naic_code)
8194 )
8195 ) and
8196 exists
8197 (
8198 select 'X'
8199 from per_pay_proposals_v2 pppv
8200 where
8201 pppv.assignment_id = paf.assignment_id and
8202 pppv.approved = 'Y' and
8203 pppv.change_date <= l_year_end
8204 )
8205 )
8206 group by region_1,meaning,employment_category,sex
8207 order by region_1,meaning,employment_category,sex;
8208
8209 v_count number(10);
8210 v_meaning hr_lookups.meaning%TYPE;
8211 v_employment_category per_assignments_f.employment_category%TYPE;
8212 v_sex per_people_f.sex%TYPE;
8213 v_region_1 hr_locations.region_1%TYPE;
8214 prev_meaning hr_lookups.meaning%TYPE := 'test';
8215 prev_employment_category per_assignments_f.employment_category%TYPE := '
8216 ';
8217 prev_naic_code hr_lookups.lookup_code%TYPE;
8218 prev_sex per_people_f.sex%TYPE := '';
8219 prev_region_1 hr_locations.region_1%TYPE;
8220
8221 cursor cur_hr_lookups is
8222 select
8223 meaning
8224 from
8225 hr_lookups
8226 where
8227 lookup_type='CA_PROVINCE' and
8228 lookup_code=v_region_1;
8229
8230 v_province_name hr_lookups.meaning%TYPE;
8231
8232 cursor cur_terminated(desig NUMBER) is
8233 select
8234 count(distinct person_id) count,
8235 meaning meaning,
8236 employment_category employment_category,
8237 sex sex,
8238 region_1 region_1
8239 from
8240 (
8241 select
8242 paf.person_id person_id,
8243 hl.meaning meaning,
8244 substr(paf.employment_category,1,2) employment_category,
8245 ppf.sex sex,
8246 hl1.region_1 region_1
8247 from
8248 hr_lookups hl,
8249 per_jobs pj,
8250 per_assignments_f paf,
8251 per_people_f ppf,
8252 per_person_types ppt,
8253 per_periods_of_service ppos ,
8254 hr_locations hl1,
8258 upper(ltrim(rtrim(hl.lookup_code)))
8255 hr_soft_coding_keyflex hsck
8256 where
8257 upper(ltrim(rtrim(hl.lookup_type)))='EEOG' and
8259 = upper(ltrim(ltrim(pj.job_information1))) and
8260 upper(ltrim(rtrim(pj.job_information_category))) = 'CA' and
8261 pj.job_id=paf.job_id and
8262 paf.primary_flag = 'Y' and
8263 --decode(paf.employment_category,'PT',p_date_tmp_emp,l_year_end) between
8264 ppos.actual_termination_date between
8265 paf.effective_start_date and
8266 paf.effective_end_date and
8267 paf.employment_category is not null and
8268 substr(paf.employment_category,1,2) in ('FR','PR','PT') and
8269 paf.location_id=hl1.location_id and
8270 paf.person_id=ppf.person_id and
8271 --decode(paf.employment_category,'PT',p_date_tmp_emp,l_year_end) between
8272 ppos.actual_termination_date between
8273 ppf.effective_start_date and
8274 ppf.effective_end_date and
8275 ppf.person_type_id = ppt.person_type_id and
8276 --UPPER(LTRIM(RTRIM(ppt.system_person_type)))='EX_EMP' and
8277 ppf.business_group_id=p_business_group_id and
8278 ppf.person_id=ppos.person_id and
8279 ppos.actual_termination_date is not null and
8280 ppos.actual_termination_date >= l_year_start and
8281 ppos.actual_termination_date <= l_year_end and
8282 decode(desig,1,per_information5,
8283 2,per_information6,
8284 3,per_information7)='Y' and
8285 (
8286 (
8287 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
8288 hsck.segment6 is not null and
8289 hsck.segment6 = v_naic_code
8290 )
8291 OR
8292 (
8293 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
8294 hsck.segment6 is null and
8295 hsck.segment1 in (select segment3
8296 from per_ca_ee_report_lines
8297 where request_id = p_request_id and
8298 context = 'FORM13' and
8299 segment1 = 'NAIC' and
8300 segment2 = v_naic_code)
8301 )
8302 ) and
8303 exists
8304 (
8305 select 'X'
8306 from per_pay_proposals_v2 pppv
8307 where
8308 pppv.assignment_id = paf.assignment_id and
8309 pppv.approved = 'Y' and
8310 pppv.change_date <= l_year_end
8311 )
8312 union all
8313 select
8314 paf.person_id person_id,
8315 hl.meaning meaning,
8316 'FR' employment_category,
8317 ppf.sex sex,
8318 hl1.region_1 region_1
8319 from
8320 hr_lookups hl,
8321 per_jobs pj,
8322 per_assignments_f paf,
8323 per_people_f ppf,
8324 per_person_types ppt,
8325 per_periods_of_service ppos ,
8326 hr_locations hl1,
8327 hr_soft_coding_keyflex hsck
8328 where
8329 upper(ltrim(rtrim(hl.lookup_type)))='EEOG' and
8330 upper(ltrim(rtrim(hl.lookup_code)))
8331 = upper(ltrim(ltrim(pj.job_information1))) and
8332 upper(ltrim(rtrim(pj.job_information_category))) = 'CA' and
8333 pj.job_id=paf.job_id and
8334 paf.primary_flag = 'Y' and
8335 --l_year_end between
8336 ppos.actual_termination_date between
8337 paf.effective_start_date and
8338 paf.effective_end_date and
8339 (paf.employment_category is null OR
8340 substr(paf.employment_category,1,2) in ('FR','PR','PT')) and
8341 paf.location_id=hl1.location_id and
8342 paf.person_id=ppf.person_id and
8343 --l_year_end between
8344 ppos.actual_termination_date between
8345 ppf.effective_start_date and
8346 ppf.effective_end_date and
8347 ppf.person_type_id = ppt.person_type_id and
8348 --UPPER(LTRIM(RTRIM(ppt.system_person_type)))='EX_EMP' and
8349 ppf.business_group_id=p_business_group_id and
8350 ppf.person_id=ppos.person_id and
8351 ppos.actual_termination_date is not null and
8352 ppos.actual_termination_date >= l_year_start and
8353 ppos.actual_termination_date <= l_year_end and
8354 decode(desig,1,per_information5,
8355 2,per_information6,
8356 3,per_information7)='Y' and
8357 (
8358 (
8359 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
8360 hsck.segment6 is not null and
8361 hsck.segment6 = v_naic_code
8362 )
8363 OR
8364 (
8365 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
8366 hsck.segment6 is null and
8367 hsck.segment1 in (select segment3
8368 from per_ca_ee_report_lines
8369 where request_id = p_request_id and
8370 context = 'FORM13' and
8371 segment1 = 'NAIC' and
8372 segment2 = v_naic_code)
8373 )
8374 ) and
8375 exists
8376 (
8377 select 'X'
8378 from per_pay_proposals_v2 pppv
8379 where
8380 pppv.assignment_id = paf.assignment_id and
8381 pppv.approved = 'Y' and
8382 pppv.change_date <= l_year_end
8383 )
8384 )
8385 group by region_1,meaning,employment_category,sex
8386 order by region_1,meaning,employment_category,sex;
8387
8388 cursor cur_eeog is
8389 select
8390 meaning
8391 from
8392 hr_lookups
8393 where
8397 select
8394 lookup_type='EEOG';
8395
8396 cursor cur_notfound(p_emp_cat number) is
8398 segment2,
8399 v_meaning,
8400 decode(p_emp_cat,1,'FR',2,'PR',3,'PT') emp_category
8401 from
8402 per_ca_ee_report_lines where
8403 request_id=p_request_id and
8404 context='FORM14' and
8405 segment1='PROVINCE' and
8406 segment3 <> '0'
8407 minus
8408 select
8409 segment2,
8410 segment3,
8411 segment4
8412 from
8413 per_ca_ee_report_lines
8414 where
8415 request_id=p_request_id and
8416 context='FORM6' and
8417 segment1='PROVINCE'and
8418 segment21 = v_naic_code;
8419
8420 cursor cur_count_national is
8421 select
8422 segment3,
8423 segment4,
8424 sum(to_number(segment5)) segment5,
8425 sum(to_number(segment6)) segment6,
8426 sum(to_number(segment7)) segment7,
8427 sum(to_number(segment8)) segment8,
8428 sum(to_number(segment9)) segment9,
8429 sum(to_number(segment10)) segment10,
8430 sum(to_number(segment11)) segment11,
8431 sum(to_number(segment12)) segment12,
8432 sum(to_number(segment13)) segment13,
8433 sum(to_number(segment14)) segment14,
8434 sum(to_number(segment15)) segment15,
8435 sum(to_number(segment16)) segment16
8436 from
8437 per_ca_ee_report_lines
8438 where
8439 request_id = p_request_id and
8440 context = 'FORM6' and
8441 segment1 = 'PROVINCE' and
8442 segment21 = v_naic_code
8443 group by segment3,segment4;
8444
8445 begin
8446
8447 hr_utility.trace('Form6 starts Here !!!!!!');
8448
8449 for naic in cur_naic loop
8450
8451 v_naic_code := naic.naic_code;
8452
8453 hr_utility.trace('Form6: v_naic = ' || v_naic_code );
8454
8455 for j in cur_terminated_total
8456 loop
8457
8458 v_count := j.count_total;
8459 v_meaning := j.meaning;
8460 v_employment_category := j.employment_category;
8461 v_sex := j.sex;
8462 v_region_1 := j.region_1;
8463
8464 open cur_hr_lookups;
8465 fetch cur_hr_lookups into v_province_name;
8466 close cur_hr_lookups;
8467
8468 if ((prev_region_1 <> v_region_1) or
8469 (ltrim(rtrim(prev_meaning)) <> ltrim(rtrim(v_meaning))) or
8470 (ltrim(rtrim(prev_naic_code)) <> ltrim(rtrim(v_naic_code))) or
8471 (ltrim(rtrim(prev_employment_category)) <>
8472 ltrim(rtrim(v_employment_category)))) then
8473
8474 per_ca_ee_extract_pkg.k := per_ca_ee_extract_pkg.k + 1;
8475
8476 insert into per_ca_ee_report_lines
8477 (request_id,
8478 line_number,
8479 context,
8480 segment1,
8481 segment2,
8482 segment3,
8483 segment4,
8484 segment5,
8485 segment6,
8486 segment7,
8487 segment8,
8488 segment9,
8489 segment10,
8490 segment11,
8491 segment12,
8492 segment13,
8493 segment14,
8494 segment15,
8495 segment16,
8496 segment21
8497 ) values
8498 (p_request_id,
8499 k,
8500 'FORM6',
8501 'PROVINCE',
8502 v_province_name,
8503 v_meaning,
8504 v_employment_category,
8505 nvl(v_count,0),
8506 decode(v_sex,'F',v_count,0),
8507 decode(v_sex,'M',v_count,0),
8508 '0',
8509 '0',
8510 '0',
8511 '0',
8512 '0',
8513 '0',
8514 '0',
8515 '0',
8516 '0',
8517 v_naic_code
8518 );
8519
8520 else
8521
8522 if prev_region_1 = v_region_1 and
8523 prev_meaning = v_meaning and
8524 prev_naic_code = v_naic_code and
8525 prev_employment_category = v_employment_category and
8526 prev_sex <> v_sex then
8527
8528 if v_sex = 'M' then
8529
8530 update per_ca_ee_report_lines set
8531 segment7=nvl(v_count,0),
8532 segment5=segment5 + nvl(v_count,0)
8533 where request_id=p_request_id and
8534 line_number = per_ca_ee_extract_pkg.k and
8535 context='FORM5' and
8536 segment1='PROVINCE' and
8537 segment2=v_province_name and
8538 segment3=v_meaning and
8539 segment4=v_employment_category and
8540 segment21=v_naic_code;
8541
8542 elsif v_sex = 'F' then
8543
8544 update per_ca_ee_report_lines set
8545 segment6=nvl(v_count,0),
8546 segment5=segment5 + nvl(v_count,0)
8547 where request_id=p_request_id and
8548 line_number = per_ca_ee_extract_pkg.k and
8549 context='FORM5' and
8550 segment1='PROVINCE' and
8551 segment2=v_province_name and
8552 segment3=v_meaning and
8553 segment4=v_employment_category and
8554 segment21=v_naic_code;
8555
8559
8556 end if;
8557
8558 end if;
8560 end if;
8561
8562 prev_meaning := v_meaning;
8563 prev_employment_category := v_employment_category;
8564 prev_sex := v_sex;
8565 prev_region_1 := v_region_1;
8566 prev_naic_code := v_naic_code;
8567
8568 end loop; -- End loop cur_terminated_total
8569
8570 for i in 1..3 loop
8571
8572 for j in cur_terminated(i)
8573 loop
8574
8575 v_sex := j.sex;
8576 v_employment_category := j.employment_category;
8577 v_meaning := j.meaning;
8578 v_count := j.count;
8579 v_region_1 := j.region_1;
8580
8581 open cur_hr_lookups;
8582 fetch cur_hr_lookups into v_province_name;
8583 close cur_hr_lookups;
8584
8585 if i = 1 then
8586
8587 if v_sex = 'M' then
8588
8589 update per_ca_ee_report_lines set
8590 segment8 = nvl(segment8,0) + nvl(v_count,0),
8591 segment9 = 0,
8592 segment10 = nvl(v_count,0)
8593 where
8594 request_id = p_request_id and
8595 context = 'FORM6' and
8596 segment1 = 'PROVINCE' and
8597 segment2 = v_province_name and
8598 segment3 = v_meaning and
8599 segment3 = v_employment_category and
8600 segment21 = v_naic_code;
8601
8602 elsif v_sex = 'F' then
8603
8604 update per_ca_ee_report_lines set
8605 segment8 = nvl(segment8,0) + nvl(v_count,0),
8606 segment9 = nvl(v_count,0),
8607 segment10 = 0
8608 where
8609 request_id = p_request_id and
8610 context='FORM6' and
8611 segment1 = 'PROVINCE' and
8612 segment2 = v_province_name and
8613 segment3 = v_meaning and
8614 segment3 = v_employment_category and
8615 segment21 = v_naic_code;
8616
8617 end if;
8618
8619 elsif i = 2 then
8620
8621 if v_sex = 'M' then
8622
8623 update per_ca_ee_report_lines set
8624 segment11 = nvl(segment11,0) + nvl(v_count,0),
8625 segment12 = 0,
8626 segment13 = nvl(v_count,0)
8627 where
8628 request_id = p_request_id and
8629 context='FORM6' and
8630 segment1 = 'PROVINCE' and
8631 segment2 = v_province_name and
8632 segment3 = v_meaning and
8633 segment3 = v_employment_category and
8634 segment21 = v_naic_code;
8635
8636 elsif v_sex = 'F' then
8637
8638 update per_ca_ee_report_lines set
8639 segment11 = nvl(segment11,0) + nvl(v_count,0),
8640 segment12 = nvl(v_count,0),
8641 segment13 = 0
8642 where
8643 request_id = p_request_id and
8644 context='FORM6' and
8645 segment1 = 'PROVINCE' and
8646 segment2 = v_province_name and
8647 segment3 = v_meaning and
8648 segment3 = v_employment_category and
8649 segment21 = v_naic_code;
8650
8651 end if;
8652
8653 elsif i = 3 then
8654
8655 if v_sex = 'M' then
8656
8657 update per_ca_ee_report_lines set
8658 segment14 = nvl(segment14,0) + nvl(v_count,0),
8659 segment15 = 0,
8660 segment16 = nvl(v_count,0)
8661 where
8662 request_id = p_request_id and
8663 context='FORM6' and
8664 segment1 = 'PROVINCE' and
8665 segment2 = v_province_name and
8666 segment3 = v_meaning and
8667 segment3 = v_employment_category and
8668 segment21 = v_naic_code;
8669
8670 elsif v_sex = 'F' then
8671
8672 update per_ca_ee_report_lines set
8673 segment14 = nvl(segment14,0) + nvl(v_count,0),
8674 segment15 = nvl(v_count,0),
8675 segment16 = 0
8676 where
8677 request_id = p_request_id and
8678 context='FORM6' and
8679 segment1 = 'PROVINCE' and
8680 segment2 = v_province_name and
8681 segment3 = v_meaning and
8682 segment3 = v_employment_category and
8683 segment21 = v_naic_code;
8684
8685 end if;
8686 end if;
8687
8688 end loop; -- End loop cur_terminated
8689
8690 end loop; -- End loop Designated Group
8691
8692
8693 for i in cur_eeog loop
8694
8695 v_meaning := i.meaning;
8696
8697 hr_utility.trace('Form6: cur_eeog: v_eeog' || v_meaning);
8698
8699 for emp_cat in 1..3 loop
8700
8701 for x in cur_notfound(emp_cat) loop
8702
8703 hr_utility.trace('Form6: cur_notfound' );
8704
8705 per_ca_ee_extract_pkg.k := per_ca_ee_extract_pkg.k + 1;
8706
8707 insert into per_ca_ee_report_lines
8708 (request_id,
8709 line_number,
8710 context,
8711 segment1,
8712 segment2,
8713 segment3,
8714 segment4,
8715 segment5,
8716 segment6,
8717 segment7,
8718 segment8,
8719 segment9,
8720 segment10,
8721 segment11,
8722 segment12,
8723 segment13,
8724 segment14,
8725 segment15,
8726 segment16,
8727 segment21) values
8728 ( p_request_id,
8729 per_ca_ee_extract_pkg.k,
8730 'FORM6',
8731 'PROVINCE',
8732 x.segment2,
8733 v_meaning,
8734 x.emp_category,
8735 0,
8736 0,
8737 0,
8738 0,
8739 0,
8740 0,
8741 0,
8742 0,
8743 0,
8744 0,
8745 0,
8746 0,
8747 v_naic_code);
8748
8749 end loop; -- End loop cur_notfound
8750
8751 end loop; -- End loop emp_cat
8752
8753 end loop; -- End loop cur_eeog
8754
8755 for count_national in cur_count_national loop
8756
8757 hr_utility.trace('Form6: cur_count_national. ');
8758
8759 insert into per_ca_ee_report_lines
8760 (request_id,
8761 line_number,
8762 context,
8763 segment1,
8764 segment2,
8765 segment3,
8766 segment4,
8767 segment5,
8768 segment6,
8769 segment7,
8770 segment8,
8771 segment9,
8772 segment10,
8773 segment11,
8774 segment12,
8775 segment13,
8776 segment14,
8777 segment15,
8778 segment21) values
8779 ( p_request_id,
8780 per_ca_ee_extract_pkg.k,
8781 'FORM6',
8782 'NATIONAL',
8783 count_national.segment3,
8784 count_national.segment4,
8785 count_national.segment5,
8786 count_national.segment6,
8787 count_national.segment7,
8788 count_national.segment8,
8789 count_national.segment9,
8790 count_national.segment10,
8791 count_national.segment11,
8792 count_national.segment12,
8793 count_national.segment13,
8794 count_national.segment14,
8795 count_national.segment15,
8796 count_national.segment16,
8797 v_naic_code);
8798
8799 end loop; -- End loop cur_count_total
8800
8801 prev_naic_code := v_naic_code;
8802
8803 end loop; --End loop of cur_naic
8804
8805 return 1;
8806
8807 end;
8808 end form6;
8809
8810
8811 function update_rec(p_request_id number) return number is
8812
8813 begin
8814
8815 declare
8816
8817 cursor cur_temp_count is select
8818 segment13,
8819 segment14,
8820 segment15
8821 from
8822 per_ca_ee_report_lines
8823 where
8824 request_id=p_request_id and
8825 context='FORM11';
8826
8827 v_tot_fr number;
8828 v_tot_pr number;
8829 v_tot_pt number;
8830
8831 cursor cur_max_naic is
8832 select
8833 segment4 max_naic_code,
8834 max(to_number(segment3))
8835 from
8836 per_ca_ee_report_lines
8837 where
8838 request_id = p_request_id and
8839 context = 'FORM12' and
8840 segment1 = 'NAIC'
8841 group by segment4;
8842
8843 v_max_naic_code hr_lookups.lookup_code%TYPE;
8844 v_max_naic_count number;
8845
8846 cursor cur_less_than_max_naic is
8847 select
8848 segment4 naic_code
8849 from
8850 per_ca_ee_report_lines
8851 where request_id = p_request_id
8852 and to_number(segment3) < (select to_number(lookup_code)
8853 from pay_ca_legislation_info
8854 where lookup_type = 'EER1')
8855 and context = 'FORM12' and
8856 segment4 <> v_max_naic_code;
8857
8858 v_not_max_naic hr_lookups.lookup_code%TYPE;
8859
8860 cursor cur_not_max_naic_data is
8861 select
8862 context,
8863 segment1,
8864 segment2,
8865 segment3,
8866 segment4,
8867 segment5,
8868 segment6,
8869 segment7,
8870 segment8,
8871 segment9,
8872 segment10,
8873 segment11,
8874 segment12,
8875 segment13,
8876 segment14,
8877 segment15,
8878 segment16,
8879 segment17,
8880 segment18,
8881 segment19,
8882 segment20
8883 segment21
8884 from per_ca_ee_report_lines
8885 where
8886 request_id = p_request_id and
8887 context in ('FORM3','FORM4','FORM5','FORM6') and
8888 segment1 = 'NATIONAL' and
8889 segment21 = v_not_max_naic;
8890
8891 begin
8892
8893 hr_utility.trace('Function update_rec starts here !!!!');
8894
8895 open cur_temp_count;
8896 fetch cur_temp_count
8897 into v_tot_fr,
8898 v_tot_pr,
8899 v_tot_pt;
8900 close cur_temp_count;
8901
8902 if (nvl(v_tot_fr,0) + nvl(v_tot_pr,0) + nvl(v_tot_pt,0)) <= 0 then
8903 return -1;
8904 else
8905
8906 if
8907 ( ((nvl(v_tot_pt,0)/(nvl(v_tot_fr,0) + nvl(v_tot_pr,0) + nvl(v_tot_pt,0))) * 100) >= 20 ) then
8908
8909 update per_ca_ee_report_lines set
8910 segment20 = 'Y'
8911 WHERE
8912 request_id=p_request_id and
8913 context in ('FORM2','FORM3','FORM4','FORM5','FORM6');
8914 else
8915
8916 update per_ca_ee_report_lines set
8917 segment20 = decode(segment3,'PT','N','Y')
8918 WHERE
8919 request_id=p_request_id and
8920 context in ('FORM2','FORM3','FORM4','FORM5','FORM6') and
8921 segment1 = 'NATIONAL';
8922
8923 update per_ca_ee_report_lines set
8924 segment20 = decode(segment4,'PT','N','Y')
8925 WHERE
8926 request_id=p_request_id and
8927 context in ('FORM2','FORM3','FORM4','FORM5','FORM6') and
8928 segment1 in ('CMA','PROVINCE');
8929
8930 end if;
8931
8932 ------------------------------------------------------------
8933 -- update the NAIC record which has more than 1000 people --
8934 -- or max number of people with other NAIC. --
8935 ------------------------------------------------------------
8936
8937 open cur_max_naic;
8938 fetch cur_max_naic
8939 into v_max_naic_code,
8940 v_max_naic_count;
8941 close cur_max_naic;
8942
8943 hr_utility.trace('UPDATE_REC: v_max_naic_code: ' || v_max_naic_code);
8944
8945 for naic in cur_less_than_max_naic loop
8946
8947 v_not_max_naic := naic.naic_code;
8948
8949 hr_utility.trace('UPDATE_REC: v_not_max_naic: ' || v_not_max_naic);
8950
8951 for i in cur_not_max_naic_data loop
8952
8953 hr_utility.trace('UPDATE_REC: Form3 - 6' );
8954
8955 update per_ca_ee_report_lines
8956 set
8957 segment4 = segment4 + i.segment4,
8958 segment5 = segment5 + i.segment5,
8959 segment6 = segment6 + i.segment6,
8960 segment7 = segment7 + i.segment7,
8961 segment8 = segment8 + i.segment8,
8962 segment9 = segment9 + i.segment9,
8963 segment10 = segment10 + i.segment10,
8964 segment11 = segment11 + i.segment11,
8965 segment12 = segment12 + i.segment12,
8966 segment13 = segment13 + i.segment13,
8967 segment14 = segment14 + i.segment14,
8968 segment15 = segment15 + i.segment15
8969 where
8970 request_id = p_request_id and
8971 context = i.context and
8972 segment1 = i.segment1 and
8973 segment2 = i.segment2 and
8974 segment3 = i.segment3 and
8975 segment21 = v_max_naic_code;
8976
8977 hr_utility.trace('UPDATE_REC: Form3 - 6 End' );
8978
8979 end loop; -- End loop cur_not_max_naic_data
8980
8981 delete from per_ca_ee_report_lines
8982 where request_id = p_request_id and
8983 segment21 = v_not_max_naic;
8984 end loop;
8985
8986 commit;
8987 return 1;
8988
8989 end if;
8990
8991 end;
8992
8993 end update_rec;
8994
8995 end per_ca_ee_extract_pkg;