[Home] [Help]
PACKAGE BODY: APPS.PER_CA_EE_EXTRACT_PKG
Source
1 PACKAGE BODY per_ca_ee_extract_pkg AS
2 /* $Header: pecaeerp.pkb 115.29 2003/06/16 19:59:09 ssouresr noship $ */
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,
47 p_end_date IN DATE,
48 p_boolean IN VARCHAR2)
49 RETURN NUMBER IS
50 v_promotions_count NUMBER := 0;
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
202 SELECT hoi.organization_id,
203 hoi.org_information8
204 FROM hr_organization_information hoi,
205 hr_organization_units hou
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
353 hoi.org_information_context = 'Canada Employer Identification' and
354 hoi.org_information8 is null;
355
356 j number := 1;
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
472 ppf.effective_end_date 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
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
499 where request_id = p_request_id and
500 context = 'FORM13' and
501 segment1 = 'NAIC' and
502 segment2 = p_naic_code)
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
599 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
596 (p_naic_code is null and
597 (
598 (
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
635 cursor cur_province_cma(pc number) is
636 select
637 count(distinct paf.person_id) count_province_cma,
638 hl1.meaning meaning
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 (
747 hl.lookup_code=hoi.org_information8 and
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
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
902 fetch cur_legislation_info
899 -- count
900
901 /* open cur_legislation_info('EER1');
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';
931 end if;
932
933 if i = 1 then
934 v_max_naic := 'Y';
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,
1076 (p_request_id,
1073 segment2,
1074 segment3,
1075 segment4) values
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
1224 context = 'FORM13' and
1221 hsck.segment1 in (select segment3
1222 from per_ca_ee_report_lines
1223 where request_id = p_request_id 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
1358 upper(ltrim(rtrim(pj.job_information_category))) = 'CA' 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
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,
1477 'FR','FR','PR','PR','PT','PT','FR') = v_employment_category and
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),
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
1609 v_max_salary_range_max := 44999;
1606 elsif v_max_salary >= 40000 and v_max_salary <= 44999 then
1607
1608 v_max_salary_range_min := 40000;
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;
1763
1760 v_min_salary_range_max := 89999;
1761
1762 elsif v_min_salary >= 90000 and v_min_salary <= 94999 then
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
1919 prev_meaning := v_meaning;
1916 prev_employment_category := v_employment_category;
1917 prev_naic_code := v_naic_code;
1918 prev_sex := v_sex;
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
2082 where
2079 update per_ca_ee_report_lines set
2080 segment15=nvl(segment15,0) + nvl(l.count,0),
2081 segment17=nvl(l.count,0)
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 select
2155 max(max_salary) max_salary,
2156 min(min_salary) min_salary,
2157 meaning meaning,
2158 employment_category employment_category,
2159 cma_province cma_province
2160 from
2161 (
2162 select
2163 trunc(to_number(pppv.proposed_salary)) * ppb.pay_annualization_factor
2164 max_salary,
2165 trunc(to_number(pppv.proposed_salary)) * ppb.pay_annualization_factor min_salary,
2166 hl.meaning meaning,
2167 substr(paf.employment_category,1,2) employment_category,
2168 decode(cma_province_count,1,hl1.region_1
2169 ,2,hl1.region_2) cma_province
2170 from
2171 hr_lookups hl,
2172 per_jobs pj,
2173 per_pay_proposals_v2 pppv,
2174 per_people_f ppf,
2175 per_assignments_f paf,
2176 hr_locations hl1,
2177 per_person_types ppt,
2178 per_ca_ee_report_lines pert,
2179 hr_lookups hl2,
2180 hr_soft_coding_keyflex hsck,
2181 per_pay_bases ppb
2182 where
2183 hl.lookup_type='EEOG' and
2184 hl.lookup_code=pj.job_information1 and
2185 pj.job_information_category='CA' and
2186 pj.job_id=paf.job_id and
2187 paf.primary_flag = 'Y' and
2188 decode(paf.employment_category,'PT',p_date_tmp_emp,l_year_end) between
2189 paf.effective_start_date and
2190 paf.effective_end_date and
2191 paf.employment_category is not null and
2192 paf.employment_category in ('FR','PR','PT') and
2193 paf.pay_basis_id = ppb.pay_basis_id and
2194 ppb.business_group_id = p_business_group_id and
2195 paf.person_id=ppf.person_id and
2196 decode(paf.employment_category,'PT',p_date_tmp_emp,l_year_end) between
2197 ppf.effective_start_date and
2198 ppf.effective_end_date and
2199 paf.assignment_id=pppv.assignment_id and
2200 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 pppv2.change_date <=
2204 decode(substr(paf.employment_category,1,2),
2205 'PT',p_date_tmp_emp,l_year_end)
2206 ) and
2207 paf.location_id=hl1.location_id and
2208 ppf.person_type_id=ppt.person_type_id and
2209 upper(ltrim(rtrim(ppt.system_person_type)))='EMP' and
2210 ppf.business_group_id=p_business_group_id and
2211 hl2.lookup_type=decode(cma_province_count,1,'CA_PROVINCE'
2212 ,2,'CA_CMA') and
2213 hl2.lookup_code=decode(cma_province_count,1,hl1.region_1
2214 ,2,hl1.region_2) and
2215 --pert.segment4 = 'Y' and
2216 pert.request_id=p_request_id and
2217 pert.context=decode(cma_province_count,1,'FORM14'
2218 ,2,'FORM13') and
2219 pert.segment1=decode(cma_province_count,1,'PROVINCE'
2220 ,2,'CMA') and
2224 (
2221 hl2.lookup_type=decode(cma_province_count,1,'CA_PROVINCE'
2222 ,2,'CA_CMA') and
2223 pert.segment2=hl2.meaning and
2225 (
2226 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
2227 hsck.segment6 is not null and
2228 hsck.segment6 = v_naic_code OR
2229 hsck.segment6 in ( select segment4
2230 from per_ca_ee_report_lines
2231 where request_id = p_request_id and
2232 context = 'FORM12' and
2233 to_number(segment3) < to_number(v_leg_info) and
2234 v_max_naic_flag = 'Y')
2235 )
2236 OR
2237 (
2238 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
2239 hsck.segment6 is null and
2240 hsck.segment1 in (select segment3
2241 from per_ca_ee_report_lines
2242 where request_id = p_request_id and
2243 context = 'FORM13' and
2244 segment1 = 'NAIC' and
2245 segment2 = v_naic_code OR
2246 segment2 in
2247 ( select segment4
2248 from per_ca_ee_report_lines
2249 where request_id = p_request_id and
2250 context = 'FORM12' and
2251 to_number(segment3)
2252 < to_number(v_leg_info) and
2253 v_max_naic_flag = 'Y')
2254 )
2255 )
2256 )
2257 union all
2258 select
2259 trunc(to_number(pppv.proposed_salary)) * ppb.pay_annualization_factor
2260 max_salary,
2261 trunc(to_number(pppv.proposed_salary)) * ppb.pay_annualization_factor
2262 min_salary,
2263 hl.meaning meaning,
2264 'FR' employment_category,
2265 decode(cma_province_count,1,hl1.region_1
2266 ,2,hl1.region_2) cma_province
2267 from
2268 hr_lookups hl,
2269 per_jobs pj,
2270 per_pay_proposals_v2 pppv,
2271 per_people_f ppf,
2272 per_assignments_f paf,
2273 hr_locations hl1,
2274 per_person_types ppt,
2275 per_ca_ee_report_lines pert,
2276 hr_lookups hl2,
2277 hr_soft_coding_keyflex hsck,
2278 per_pay_bases ppb
2279 where
2280 hl.lookup_type='EEOG' and
2281 hl.lookup_code=pj.job_information1 and
2282 pj.job_information_category='CA' and
2283 pj.job_id=paf.job_id and
2284 paf.primary_flag = 'Y' and
2285 l_year_end between
2286 paf.effective_start_date and
2287 paf.effective_end_date and
2288 (paf.employment_category is null OR
2289 paf.employment_category not in ('FR','PR','PT')
2290 ) and
2291 paf.pay_basis_id = ppb.pay_basis_id and
2292 ppb.business_group_id = p_business_group_id and
2293 paf.person_id=ppf.person_id and
2294 paf.assignment_id=pppv.assignment_id and
2295 pppv.change_date = (select max(pppv2.change_date)
2296 from per_pay_proposals_v2 pppv2
2297 where pppv2.assignment_id = paf.assignment_id
2298 and pppv2.change_date <= l_year_end
2299 ) and
2300 l_year_end between
2301 ppf.effective_start_date and
2302 ppf.effective_end_date and
2303 paf.location_id=hl1.location_id and
2304 ppf.person_type_id=ppt.person_type_id and
2305 upper(ltrim(rtrim(ppt.system_person_type)))='EMP' and
2306 ppf.business_group_id=p_business_group_id and
2307 hl2.lookup_type=decode(cma_province_count,1,'CA_PROVINCE'
2308 ,2,'CA_CMA') and
2309 hl2.lookup_code=decode(cma_province_count,1,hl1.region_1
2310 ,2,hl1.region_2) and
2311 --pert.segment4 = 'Y' and
2312 pert.request_id=p_request_id and
2313 pert.context=decode(cma_province_count,1,'FORM14'
2314 ,2,'FORM13') and
2315 pert.segment1=decode(cma_province_count,1,'PROVINCE'
2316 ,2,'CMA') and
2317 hl2.lookup_type=decode(cma_province_count,1,'CA_PROVINCE'
2318 ,2,'CA_CMA') and
2319 pert.segment2=hl2.meaning and
2320 (
2321 (
2322 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
2323 hsck.segment6 is not null and
2324 hsck.segment6 = v_naic_code OR
2325 hsck.segment6 in ( select segment4
2326 from per_ca_ee_report_lines
2327 where request_id = p_request_id and
2328 context = 'FORM12' and
2329 to_number(segment3) < to_number(v_leg_info) and
2330 v_max_naic_flag = 'Y')
2331 )
2332 OR
2333 (
2334 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
2335 hsck.segment6 is null and
2336 hsck.segment1 in (select segment3
2337 from per_ca_ee_report_lines
2338 where request_id = p_request_id and
2339 context = 'FORM13' and
2340 segment1 = 'NAIC' and
2341 segment2 = v_naic_code OR
2342 segment2 in
2346 context = 'FORM12' and
2343 ( select segment4
2344 from per_ca_ee_report_lines
2345 where request_id = p_request_id and
2347 to_number(segment3)
2348 < to_number(v_leg_info) and
2349 v_max_naic_flag = 'Y')
2350 )
2351 )
2352 )
2353 )
2354 group by meaning,employment_category,cma_province
2355 order by meaning,employment_category,cma_province;
2356
2357 v_max_salary number;
2358 v_min_salary number;
2359 v_meaning hr_lookups.meaning%TYPE;
2360 v_employment_category per_assignments_f.employment_category%TYPE;
2361 v_cma_province hr_locations.region_1%TYPE;
2362
2363 j_flag varchar2(1) := 'F';
2364
2365 cursor cur_meaning(cp number) is
2366 select
2367 meaning
2368 from
2369 hr_lookups
2370 where
2371 upper(ltrim(rtrim(lookup_type)))=decode(cp,1,'CA_PROVINCE'
2372 ,2,'CA_CMA') and
2373 upper(ltrim(rtrim(lookup_code)))=upper(ltrim(rtrim(v_cma_province)));
2374
2375 v_meaning1 hr_lookups.meaning%TYPE;
2376 v_range number;
2377 v_q1_min number;
2378 v_q1_max number;
2379 v_q2_min number;
2380 v_q2_max number;
2381 v_q3_min number;
2382 v_q3_max number;
2383 v_q4_min number;
2384 v_q4_max number;
2385
2386 v_max_salary_range_min number;
2387 v_max_salary_range_max number;
2388 v_min_salary_range_min number;
2389 v_min_salary_range_max number;
2390
2391 cursor cur_count_total(i_range number,
2392 i_x number) is
2393 select
2394 count(distinct paf.person_id) count_total,
2395 ppf.sex --sex
2396 from
2397 hr_lookups hl,
2398 per_jobs pj,
2399 per_assignments_f paf,
2400 per_people_f ppf,
2401 per_pay_proposals_v2 pppv,
2402 hr_locations hl1,
2403 per_person_types ppt,
2404 hr_soft_coding_keyflex hsck,
2405 per_pay_bases ppb
2406 where
2407 hl.lookup_type='EEOG' and
2408 upper(ltrim(rtrim(hl.meaning)))=upper(ltrim(rtrim(v_meaning))) and
2409 upper(ltrim(rtrim(hl.lookup_code)))
2410 =upper(ltrim(rtrim(pj.job_information1))) and
2411 upper(ltrim(rtrim(pj.job_information_category))) = 'CA' and
2412 pj.job_id=paf.job_id and
2413 paf.primary_flag = 'Y' and
2414 decode(paf.employment_category,'PT',p_date_tmp_emp,l_year_end) between
2415 paf.effective_start_date and
2416 paf.effective_end_date and
2417 decode(substr(NVL(paf.employment_category,'FR'),1,2),
2418 'FR','FR','PR','PR','PT','PT','FR')
2419 = ltrim(rtrim(v_employment_category)) and
2420 /* substr(NVL(paf.employment_category,'FR'),1,2) =
2421 ltrim(rtrim(v_employment_category)) and */
2422 paf.person_id=ppf.person_id and
2423 decode(paf.employment_category,'PT',p_date_tmp_emp,l_year_end) between
2424 ppf.effective_start_date and
2425 ppf.effective_end_date and
2426 paf.pay_basis_id = ppb.pay_basis_id and
2427 ppb.business_group_id = p_business_group_id and
2428 ppf.person_type_id=ppt.person_type_id and
2429 upper(ltrim(rtrim(ppt.system_person_type)))='EMP' and
2430 ppf.business_group_id=p_business_group_id and
2431 paf.location_id=hl1.location_id and
2432 decode(i_x,1,hl1.region_1,
2433 2,hl1.region_2) = v_cma_province and
2434 paf.assignment_id=pppv.assignment_id and
2435 pppv.change_date = (select max(pppv2.change_date)
2436 from per_pay_proposals_v2 pppv2
2437 where pppv2.assignment_id = paf.assignment_id
2438 and pppv2.change_date <=
2439 decode(substr(paf.employment_category,1,2),
2440 'PT',p_date_tmp_emp,l_year_end)
2441 ) and
2442 trunc(to_number(pppv.proposed_salary)) * ppb.pay_annualization_factor
2443 >= decode(i_range,1,v_q1_min,
2444 2,v_q2_min,
2445 3,v_q3_min,
2446 4,v_q4_min) and
2447 trunc(to_number(pppv.proposed_salary)) * ppb.pay_annualization_factor
2448 <= decode(i_range,1,v_q1_max,
2449 2,v_q2_max,
2450 3,v_q3_max,
2451 4,v_q4_max) and
2452 (
2453 (
2454 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
2455 hsck.segment6 is not null and
2456 hsck.segment6 = v_naic_code OR
2457 hsck.segment6 in ( select segment4
2458 from per_ca_ee_report_lines
2459 where request_id = p_request_id and
2460 context = 'FORM12' and
2461 to_number(segment3) < to_number(v_leg_info) and
2462 v_max_naic_flag = 'Y')
2463 )
2464 OR
2465 (
2466 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
2467 hsck.segment6 is null and
2468 hsck.segment1 in (select segment3
2469 from per_ca_ee_report_lines
2473 segment2 = v_naic_code OR
2470 where request_id = p_request_id and
2471 context = 'FORM13' and
2472 segment1 = 'NAIC' and
2474 segment2 in
2475 ( select segment4
2476 from per_ca_ee_report_lines
2477 where request_id = p_request_id and
2478 context = 'FORM12' and
2479 to_number(segment3)
2480 < to_number(v_leg_info) and
2481 v_max_naic_flag = 'Y')
2482 )
2483 )
2484 )
2485 group by ppf.sex
2486 order by ppf.sex;
2487
2488 v_count number(10);
2489 v_sex per_people_f.sex%TYPE;
2490 prev_employment_category per_assignments_f.employment_category%TYPE;
2491 prev_sex per_people_f.sex%TYPE;
2492 prev_j number := 0;
2493 prev_cma_province hr_locations.region_1%TYPE;
2494 prev_naic_code hr_lookups.lookup_code%TYPE;
2495 prev_meaning hr_lookups.meaning%TYPE;
2496
2497 cursor cur_count(range number,
2498 desig number,
2499 i_y number) is
2500 select
2501 count(distinct paf.person_id) count,
2502 ppf.sex --sex
2503 from
2504 hr_lookups hl,
2505 per_jobs pj,
2506 per_assignments_f paf,
2507 per_people_f ppf,
2508 per_pay_proposals_v2 pppv,
2509 hr_locations hl1,
2510 per_person_types ppt,
2511 hr_soft_coding_keyflex hsck,
2512 per_pay_bases ppb
2513 where
2514 hl.lookup_type='EEOG' and
2515 upper(ltrim(rtrim(hl.meaning)))=upper(ltrim(rtrim(v_meaning))) and
2516 upper(ltrim(rtrim(hl.lookup_code)))
2517 = upper(ltrim(rtrim(pj.job_information1))) and
2518 upper(ltrim(rtrim(pj.job_information_category))) = 'CA' and
2519 pj.job_id=paf.job_id and
2520 paf.primary_flag = 'Y' and
2521 decode(paf.employment_category,'PT',p_date_tmp_emp,l_year_end) between
2522 paf.effective_start_date and
2523 paf.effective_end_date and
2524 paf.pay_basis_id = ppb.pay_basis_id and
2525 ppb.business_group_id = p_business_group_id and
2526 paf.location_id=hl1.location_id and
2527 decode(i_y,1,hl1.region_1,
2528 2,hl1.region_2) = v_cma_province and
2529 paf.person_id=ppf.person_id and
2530 decode(paf.employment_category,'PT',p_date_tmp_emp,l_year_end) between
2531 ppf.effective_start_date and
2532 ppf.effective_end_date and
2533 ppf.person_type_id=ppt.person_type_id and
2534 upper(ltrim(rtrim(ppt.system_person_type)))='EMP' and
2535 ppf.business_group_id=p_business_group_id and
2536 decode(desig,1,per_information5,
2537 2,per_information6,
2538 3,per_information7)='Y' and
2539 --substr(NVL(paf.employment_category,'FR'),1,2)=v_employment_category and
2540 decode(substr(NVL(paf.employment_category,'FR'),1,2),
2541 'FR','FR','PR','PR','PT','PT','FR')
2542 = ltrim(rtrim(v_employment_category)) and
2543 paf.assignment_id=pppv.assignment_id and
2544 pppv.change_date = (select max(pppv2.change_date)
2545 from per_pay_proposals_v2 pppv2
2546 where pppv2.assignment_id = paf.assignment_id
2547 and pppv2.change_date <=
2548 decode(substr(paf.employment_category,1,2),
2549 'PT',p_date_tmp_emp,l_year_end)
2550 ) and
2551 trunc(to_number(pppv.proposed_salary)) * ppb.pay_annualization_factor
2552 >= decode(range,1,v_q1_min,
2553 2,v_q2_min,
2554 3,v_q3_min,
2555 4,v_q4_min) and
2556 trunc(to_number(pppv.proposed_salary)) * ppb.pay_annualization_factor
2557 <= decode(range,1,v_q1_max,
2558 2,v_q2_max,
2559 3,v_q3_max,
2560 4,v_q4_max) and
2561 (
2562 (
2563 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
2564 hsck.segment6 is not null and
2565 hsck.segment6 = v_naic_code OR
2566 hsck.segment6 in ( select segment4
2567 from per_ca_ee_report_lines
2568 where request_id = p_request_id and
2569 context = 'FORM12' and
2570 to_number(segment3) < to_number(v_leg_info) and
2571 v_max_naic_flag = 'Y')
2572 )
2573 OR
2574 (
2575 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
2576 hsck.segment6 is null and
2577 hsck.segment1 in (select segment3
2578 from per_ca_ee_report_lines
2579 where request_id = p_request_id and
2580 context = 'FORM13' and
2581 segment1 = 'NAIC' and
2582 segment2 = v_naic_code OR
2583 segment2 in
2584 ( select segment4
2585 from per_ca_ee_report_lines
2586 where request_id = p_request_id and
2587 context = 'FORM12' and
2588 to_number(segment3)
2589 < to_number(v_leg_info) and
2590 v_max_naic_flag = 'Y')
2591 )
2592 )
2593 )
2597 begin
2594 group by ppf.sex
2595 order by ppf.sex;
2596
2598
2599 open cur_legislation_info('EER1');
2600 fetch cur_legislation_info
2601 into v_leg_info;
2602 close cur_legislation_info;
2603
2604 hr_utility.trace('Form2 starts Here !!!');
2605
2606 for naic in cur_naic loop
2607
2608 v_tot_number_emp := naic.tot_number_emp;
2609 v_naic_code := naic.naic_code;
2610 v_max_naic_flag := naic.max_naic_flag;
2611
2612 if ( (v_max_naic_flag = 'Y') OR
2613 (to_number(v_tot_number_emp) >= to_number(v_leg_info)) ) then
2614
2615 for x in 1..2 loop
2616
2617 for i in cur_min_max(x) loop
2618
2619 hr_utility.trace('Form2: cur_min_max');
2620
2621 v_max_salary := nvl(to_number(i.max_salary),0);
2622 v_min_salary := nvl(to_number(i.min_salary),0);
2623 v_meaning := i.meaning;
2624 v_employment_category := i.employment_category;
2625 v_cma_province := i.cma_province;
2626
2627
2628 hr_utility.trace('Form2: v_cma_province: ' || v_cma_province);
2629 hr_utility.trace('Form2: v_employment_category: ' || v_employment_category);
2630 hr_utility.trace('Form2: v_meaning: ' || v_meaning);
2631
2632 open cur_meaning(x);
2633 fetch cur_meaning into v_meaning1;
2634 close cur_meaning;
2635
2636 -- To check the salary range in the predefined
2637 -- salary ranges
2638
2639 if v_max_salary >= 0 and v_max_salary < 5000 then
2640
2641 v_max_salary_range_min := 0;
2642 v_max_salary_range_max := 5000;
2643
2644 elsif v_max_salary >= 5000 and v_max_salary <= 9999 then
2645
2646 v_max_salary_range_min := 5000;
2647 v_max_salary_range_max := 9999;
2648
2649 elsif v_max_salary >= 10000 and v_max_salary <= 14999 then
2650
2651 v_max_salary_range_min := 10000;
2652 v_max_salary_range_max := 14999;
2653
2654 elsif v_max_salary >= 15000 and v_max_salary <= 19999 then
2655
2656 v_max_salary_range_min := 15000;
2657 v_max_salary_range_max := 19999;
2658
2659 elsif v_max_salary >= 20000 and v_max_salary <= 24999 then
2660
2661 v_max_salary_range_min := 20000;
2662 v_max_salary_range_max := 24999;
2663
2664 elsif v_max_salary >= 25000 and v_max_salary <= 29999 then
2665
2666 v_max_salary_range_min := 25000;
2667 v_max_salary_range_max := 29999;
2668
2669 elsif v_max_salary >= 30000 and v_max_salary <= 34999 then
2670
2671 v_max_salary_range_min := 30000;
2672 v_max_salary_range_max := 34999;
2673
2674 elsif v_max_salary >= 35000 and v_max_salary <= 39999 then
2675
2676 v_max_salary_range_min := 35000;
2677 v_max_salary_range_max := 39999;
2678
2679 elsif v_max_salary >= 40000 and v_max_salary <= 44999 then
2680
2681 v_max_salary_range_min := 40000;
2682 v_max_salary_range_max := 44999;
2683
2684 elsif v_max_salary >= 45000 and v_max_salary <= 49999 then
2685
2686 v_max_salary_range_min := 45000;
2687 v_max_salary_range_max := 49999;
2688
2689 elsif v_max_salary >= 50000 and v_max_salary <= 54999 then
2690
2691 v_max_salary_range_min := 50000;
2692 v_max_salary_range_max := 54999;
2693
2694 elsif v_max_salary >= 55000 and v_max_salary <= 59999 then
2695
2696 v_max_salary_range_min := 55000;
2697 v_max_salary_range_max := 59999;
2698
2699 elsif v_max_salary >= 60000 and v_max_salary <= 64999 then
2700
2701 v_max_salary_range_min := 60000;
2702 v_max_salary_range_max := 64999;
2703
2704 elsif v_max_salary >= 65000 and v_max_salary <= 69999 then
2705
2706 v_max_salary_range_min := 65000;
2707 v_max_salary_range_max := 69999;
2708
2709 elsif v_max_salary >= 70000 and v_max_salary <= 74999 then
2710
2711 v_max_salary_range_min := 70000;
2712 v_max_salary_range_max := 74999;
2713
2714 elsif v_max_salary >= 75000 and v_max_salary <= 79999 then
2715
2716 v_max_salary_range_min := 75000;
2717 v_max_salary_range_max := 79999;
2718
2719 elsif v_max_salary >= 80000 and v_max_salary <= 84999 then
2720
2721 v_max_salary_range_min := 80000;
2722 v_max_salary_range_max := 84999;
2723
2724 elsif v_max_salary >= 85000 and v_max_salary <= 89999 then
2725
2726 v_max_salary_range_min := 85000;
2727 v_max_salary_range_max := 89999;
2728
2729 elsif v_max_salary >= 90000 and v_max_salary <= 94999 then
2730
2731 v_max_salary_range_min := 90000;
2732 v_max_salary_range_max := 94999;
2733
2734 elsif v_max_salary >= 95000 and v_max_salary <= 99999 then
2735
2736 v_max_salary_range_min := 95000;
2737 v_max_salary_range_max := 99999;
2738
2739 elsif v_max_salary > 100000 then
2740
2741 v_max_salary_range_min := 100000;
2742 v_max_salary_range_max := 9999999;
2743
2744 end if ;
2745
2746 if v_min_salary >= 0 and v_min_salary < 5000 then
2747
2748 v_min_salary_range_min := 0;
2752
2749 v_min_salary_range_max := 5000;
2750
2751 elsif v_min_salary >= 5000 and v_min_salary <= 9999 then
2753 v_min_salary_range_min := 5000;
2754 v_min_salary_range_max := 9999;
2755
2756 elsif v_min_salary >= 10000 and v_min_salary <= 14999 then
2757
2758 v_min_salary_range_min := 10000;
2759 v_min_salary_range_max := 14999;
2760
2761 elsif v_min_salary >= 15000 and v_min_salary <= 19999 then
2762
2763 v_min_salary_range_min := 15000;
2764 v_min_salary_range_max := 19999;
2765
2766 elsif v_min_salary >= 20000 and v_min_salary <= 24999 then
2767
2768 v_min_salary_range_min := 20000;
2769 v_min_salary_range_max := 24999;
2770
2771 elsif v_min_salary >= 25000 and v_min_salary <= 29999 then
2772
2773 v_min_salary_range_min := 25000;
2774 v_min_salary_range_max := 29999;
2775
2776 elsif v_min_salary >= 30000 and v_min_salary <= 34999 then
2777
2778 v_min_salary_range_min := 30000;
2779 v_min_salary_range_max := 34999;
2780
2781 elsif v_min_salary >= 35000 and v_min_salary <= 39999 then
2782
2783 v_min_salary_range_min := 35000;
2784 v_min_salary_range_max := 39999;
2785
2786 elsif v_min_salary >= 40000 and v_min_salary <= 44999 then
2787
2788 v_min_salary_range_min := 40000;
2789 v_min_salary_range_max := 44999;
2790
2791 elsif v_min_salary >= 45000 and v_min_salary <= 49999 then
2792
2793 v_min_salary_range_min := 45000;
2794 v_min_salary_range_max := 49999;
2795
2796 elsif v_min_salary >= 50000 and v_min_salary <= 54999 then
2797
2798 v_min_salary_range_min := 50000;
2799 v_min_salary_range_max := 54999;
2800
2801 elsif v_min_salary >= 55000 and v_min_salary <= 59999 then
2802
2803 v_min_salary_range_min := 55000;
2804 v_min_salary_range_max := 59999;
2805
2806 elsif v_min_salary >= 60000 and v_min_salary <= 64999 then
2807
2808 v_min_salary_range_min := 60000;
2809 v_min_salary_range_max := 64999;
2810
2811 elsif v_min_salary >= 65000 and v_min_salary <= 69999 then
2812
2813 v_min_salary_range_min := 65000;
2814 v_min_salary_range_max := 69999;
2815
2816 elsif v_min_salary >= 70000 and v_min_salary <= 74999 then
2817
2818 v_min_salary_range_min := 70000;
2819 v_min_salary_range_max := 74999;
2820
2821 elsif v_min_salary >= 75000 and v_min_salary <= 79999 then
2822
2823 v_min_salary_range_min := 75000;
2824 v_min_salary_range_max := 79999;
2825
2826 elsif v_min_salary >= 80000 and v_min_salary <= 84999 then
2827
2828 v_min_salary_range_min := 80000;
2829 v_min_salary_range_max := 84999;
2830
2831 elsif v_min_salary >= 85000 and v_min_salary <= 89999 then
2832
2833 v_min_salary_range_min := 85000;
2834 v_min_salary_range_max := 89999;
2835
2836 elsif v_min_salary >= 90000 and v_min_salary <= 94999 then
2837
2838 v_min_salary_range_min := 90000;
2839 v_min_salary_range_max := 94999;
2840
2841 elsif v_min_salary >= 95000 and v_min_salary <= 99999 then
2842
2843 v_min_salary_range_min := 95000;
2844 v_min_salary_range_max := 99999;
2845
2846 elsif v_min_salary > 100000 then
2847
2848 v_min_salary_range_min := 100000;
2849 v_min_salary_range_max := 9999999;
2850
2851 end if;
2852
2853 v_range := (nvl(v_max_salary,0)-nvl(v_min_salary,0))/4;
2854
2855 v_q1_min := nvl(v_min_salary,0);
2856 v_q1_max := v_q1_min + v_range;
2857
2858 v_q2_min := v_q1_max + 1;
2859 v_q2_max := v_q2_min + v_range - 1;
2860
2861 v_q3_min := v_q2_max + 1;
2862 v_q3_max := v_q3_min + v_range - 1;
2863
2864 v_q4_min := v_q3_max + 1;
2865 v_q4_max := v_q4_min + v_range -1;
2866
2867 for j in 1..4 loop
2868
2869 j_flag := 'F';
2870
2871 for l in cur_count_total(j,x) loop
2872
2873 v_count := l.count_total;
2874 v_sex := l.sex;
2875
2876 if
2877 (
2878 (ltrim(rtrim(prev_cma_province)) <> ltrim(rtrim(v_meaning1))) or
2879 (ltrim(rtrim(prev_naic_code)) <> ltrim(rtrim(v_naic_code))) or
2880 (ltrim(rtrim(prev_meaning)) <> ltrim(rtrim(v_meaning))) or
2881 (ltrim(rtrim(prev_employment_category)) <>
2882 ltrim(rtrim(v_employment_category))) or
2883 (prev_j <> j)
2884 ) then
2885
2886 per_ca_ee_extract_pkg.k := per_ca_ee_extract_pkg.k + 1;
2887
2888 insert into per_ca_ee_report_lines
2889 ( request_id,
2890 line_number,
2891 context,
2892 segment1,
2893 segment2,
2894 segment3,
2895 segment4,
2896 segment5,
2897 segment6,
2898 segment7,
2899 segment8,
2900 segment9,
2901 segment10,
2902 segment11,
2903 segment12,
2904 segment13,
2905 segment14,
2906 segment15,
2907 segment16,
2908 segment17,
2909 segment18,
2910 segment21) values
2911 ( p_request_id,
2915 ,2,'CMA'),
2912 per_ca_ee_extract_pkg.k,
2913 'FORM2',
2914 decode(x,1,'PROVINCE'
2916 v_meaning1,
2917 v_meaning,
2918 v_employment_category,
2919 v_min_salary_range_min||'..'||
2920 v_min_salary_range_max||' '||
2921 v_max_salary_range_min||'..'||
2922 v_max_salary_range_max,
2923 to_char(j),
2924 nvl(v_count,0),
2925 decode(v_sex,'F',v_count,0),
2926 decode(v_sex,'M',v_count,0),
2927 '0',
2928 '0',
2929 '0',
2930 '0',
2931 '0',
2932 '0',
2933 '0',
2934 '0',
2935 '0',
2936 v_naic_code) ;
2937
2938 j_flag := 'T';
2939 else
2940 if prev_cma_province = v_meaning1 and
2941 prev_employment_category = v_employment_category and
2942 prev_naic_code = v_naic_code and
2943 prev_meaning = v_meaning and
2944 prev_sex <> v_sex then
2945
2946 if v_sex = 'M' then
2947
2948 update per_ca_ee_report_lines set
2949 segment7=segment7 + nvl(v_count,0),
2950 segment9=nvl(v_count,0)
2951 where request_id=p_request_id and
2952 line_number=per_ca_ee_extract_pkg.k and
2953 segment1=decode(x,1,'PROVINCE',
2954 2,'CMA') and
2955 segment2=v_meaning1 and
2956 segment21 = v_naic_code;
2957
2958 elsif v_sex = 'F' 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 end if;
2971 end if;
2972 end if;
2973
2974 prev_cma_province := v_meaning1;
2975 prev_employment_category := v_employment_category;
2976 prev_sex := v_sex;
2977 prev_j := j;
2978 prev_naic_code := v_naic_code;
2979 prev_meaning := v_meaning;
2980
2981 end loop;
2982
2983
2984 if j_flag = 'F' then
2985
2986 per_ca_ee_extract_pkg.k := per_ca_ee_extract_pkg.k + 1;
2987
2988 insert into per_ca_ee_report_lines
2989 ( request_id,
2990 line_number,
2991 context,
2992 segment1,
2993 segment2,
2994 segment3,
2995 segment4,
2996 segment5,
2997 segment6,
2998 segment7,
2999 segment8,
3000 segment9,
3001 segment10,
3002 segment11,
3003 segment12,
3004 segment13,
3005 segment14,
3006 segment15,
3007 segment16,
3008 segment17,
3009 segment18,
3010 segment21) values
3011 ( p_request_id,
3012 per_ca_ee_extract_pkg.k,
3013 'FORM2',
3014 decode(x,1,'PROVINCE'
3015 ,2,'CMA'),
3016 v_meaning1,
3017 v_meaning,
3018 v_employment_category,
3019 v_min_salary_range_min||'..'||
3020 v_min_salary_range_max||' '||
3021 v_max_salary_range_min||'..'||
3022 v_max_salary_range_max,
3023 to_char(j),
3024 '0',
3025 '0',
3026 '0',
3027 '0',
3028 '0',
3029 '0',
3030 '0',
3031 '0',
3032 '0',
3033 '0',
3034 '0',
3035 '0',
3036 v_naic_code);
3037
3038 j_flag := 'T';
3039
3040 end if ;
3041
3042 end loop;
3043 ---------------------------------
3044 -- Updation designated Group --
3045 ---------------------------------
3046
3047 for j in 1..4 loop
3048
3049 for k in 1..3 loop
3050
3051 for l in cur_count(j,k,x) loop
3052
3053 if k = 1 then
3054
3055 if l.sex = 'F' then
3056
3057 update per_ca_ee_report_lines set
3058 segment10=nvl(segment10,0) + nvl(l.count,0),
3059 segment11=nvl(l.count,0)
3060 where
3061 request_id=p_request_id and
3062 context='FORM2' and
3063 ltrim(rtrim(segment1))=decode(x,1,'PROVINCE'
3064 ,2,'CMA') and
3065 ltrim(rtrim(segment2))=ltrim(rtrim(v_meaning1)) and
3066 upper(ltrim(rtrim(segment3)))=upper(ltrim(rtrim(v_meaning))) and
3067 upper(ltrim(rtrim(segment4)))
3068 =upper(ltrim(rtrim(v_employment_category))) and
3069 segment6=to_char(j) and
3070 segment21 = v_naic_code;
3071
3072 elsif l.sex = 'M' then
3073
3074 update per_ca_ee_report_lines set
3075 segment10=nvl(segment10,0) + nvl(l.count,0),
3076 segment12=nvl(l.count,0)
3077 where
3078 request_id=p_request_id and
3079 context='FORM2' and
3083 upper(ltrim(rtrim(segment3))) =
3080 ltrim(rtrim(segment1))=decode(x,1,'PROVINCE'
3081 ,2,'CMA') and
3082 ltrim(rtrim(segment2))=ltrim(rtrim(v_meaning1)) and
3084 upper(ltrim(rtrim(v_meaning))) and
3085 upper(ltrim(rtrim(segment4))) =
3086 upper(ltrim(rtrim(v_employment_category))) and
3087 segment6=to_char(j) and
3088 segment21 = v_naic_code;
3089
3090 end if;
3091
3092 elsif k = 2 then
3093
3094 if l.sex = 'F' then
3095
3096 update per_ca_ee_report_lines set
3097 segment13=nvl(segment13,0) + nvl(l.count,0),
3098 segment14=nvl(l.count,0)
3099 where
3100 request_id=p_request_id and
3101 context='FORM2' and
3102 ltrim(rtrim(segment1))=decode(x,1,'PROVINCE'
3103 ,2,'CMA') and
3104 ltrim(rtrim(segment2))=ltrim(rtrim(v_meaning1)) and
3105 upper(ltrim(rtrim(segment3)))=upper(ltrim(rtrim(v_meaning))) and
3106 upper(ltrim(rtrim(segment4)))=
3107 upper(ltrim(rtrim(v_employment_category))) and
3108 segment6=to_char(j) and
3109 segment21 = v_naic_code;
3110 else
3111
3112 update per_ca_ee_report_lines set
3113 segment13=nvl(segment13,0) + nvl(l.count,0),
3114 segment15=nvl(l.count,0)
3115 where
3116 request_id=p_request_id and
3117 context='FORM2' and
3118 ltrim(rtrim(segment1))=decode(x,1,'PROVINCE'
3119 ,2,'CMA') and
3120 ltrim(rtrim(segment2))=ltrim(rtrim(v_meaning1)) and
3121 upper(ltrim(rtrim(segment3))) = upper(ltrim(rtrim(v_meaning))) and
3122 upper(ltrim(rtrim(segment4))) =
3123 upper(ltrim(rtrim(v_employment_category))) and
3124 segment6=to_char(j) and
3125 segment21 = v_naic_code;
3126
3127 end if;
3128
3129 elsif k = 3 then
3130
3131 if l.sex = 'F' then
3132
3133 update per_ca_ee_report_lines set
3134 segment16=nvl(segment16,0) + nvl(l.count,0),
3135 segment17=nvl(l.count,0)
3136 where
3137 request_id=p_request_id and
3138 context='FORM2' and
3139 ltrim(rtrim(segment1))=decode(x,1,'PROVINCE'
3140 ,2,'CMA') and
3141 ltrim(rtrim(segment2))=ltrim(rtrim(v_meaning1)) and
3142 upper(ltrim(rtrim(segment3)))=upper(ltrim(rtrim(v_meaning))) and
3143 upper(ltrim(rtrim(segment4)))=
3144 upper(ltrim(rtrim(v_employment_category))) and
3145 segment6=to_char(j) and
3146 segment21 = v_naic_code;
3147
3148 else
3149
3150 update per_ca_ee_report_lines set
3151 segment16=nvl(segment16,0) + nvl(l.count,0),
3152 segment18=nvl(l.count,0)
3153 where
3154 request_id=p_request_id and
3155 context='FORM2' and
3156 ltrim(rtrim(segment1))=decode(x,1,'PROVINCE'
3157 ,2,'CMA') and
3158 ltrim(rtrim(segment2))=ltrim(rtrim(v_meaning1)) and
3159 upper(ltrim(rtrim(segment3)))=upper(ltrim(rtrim(v_meaning))) and
3160 upper(ltrim(rtrim(segment4))) =
3161 upper(ltrim(rtrim(v_employment_category))) and
3162 segment6=to_char(j) and
3163 segment21 = v_naic_code;
3164
3165 end if;
3166
3167 end if;
3168 end loop;
3169 end loop;
3170 end loop;
3171
3172 end loop;
3173 end loop;
3174
3175 prev_naic_code := v_naic_code;
3176
3177 end if; -- if v_max_naic_code = Y or segment3 greater than v_leg_info.
3178
3179 end loop; -- End loop cur_naic
3180
3181 return 1;
3182 end;
3183
3184 end form2;
3185
3186
3187 function form3(p_business_group_id in number,
3188 p_request_id in number,
3189 p_year in varchar2,
3190 p_date_tmp_emp in date) return number is
3191
3192 --l_year_start date;
3193 l_year_end date;
3194
3195 begin
3196
3197 --l_year_start := trunc(to_date(p_year,'YYYY'),'Y');
3198 l_year_end := add_months(trunc(to_date(p_year,'YYYY'),'Y'), 12) -1;
3199
3200 declare
3201
3202 cursor cur_naic is
3203 select
3204 pert.segment4 naic_code
3205 from
3206 per_ca_ee_report_lines pert
3207 where
3208 pert.request_id = p_request_id and
3209 pert.context = 'FORM12';
3210
3211 v_naic_code hr_lookups.lookup_code%TYPE;
3212
3213 v_min_range number;
3214 v_max_range number;
3215 v_fr_min_range number;
3216 v_fr_max_range number;
3217
3218 cursor cur_count_total(cma_province_count number,
3219 range number) is
3220 select
3221 count(distinct count_total) count_total,
3222 employment_category employment_category,
3223 sex sex,
3224 cma_province cma_province
3225 from
3226 (
3227 select
3231 decode(cma_province_count,1,hl1.region_1,2,hl1.region_2) cma_province
3228 paf.person_id count_total,
3229 substr(paf.employment_category,1,2) employment_category,
3230 ppf.sex sex,
3232 from
3233 per_jobs pj,
3234 per_assignments_f paf,
3235 per_people_f ppf,
3236 per_pay_proposals_v2 pppv,
3237 per_person_types ppt,
3238 hr_locations hl1,
3239 per_ca_ee_report_lines pert,
3240 hr_lookups hl2,
3241 hr_soft_coding_keyflex hsck,
3242 per_pay_bases ppb
3243 where
3244 upper(ltrim(rtrim(pj.job_information_category))) = 'CA' and
3245 pj.job_id=paf.job_id and
3246 paf.primary_flag = 'Y' and
3247 decode(paf.employment_category,'PT',p_date_tmp_emp,l_year_end) between
3248 paf.effective_start_date and
3249 paf.effective_end_date and
3250 paf.employment_category is not null and
3251 substr(paf.employment_category,1,2) in ('FR','PR','PT') and
3252 paf.person_id=ppf.person_id and
3253 decode(paf.employment_category,'PT',p_date_tmp_emp,l_year_end) between
3254 ppf.effective_start_date and
3255 ppf.effective_end_date and
3256 paf.pay_basis_id = ppb.pay_basis_id and
3257 ppb.business_group_id = p_business_group_id and
3258 ppf.person_type_id=ppt.person_type_id and
3259 upper(ltrim(rtrim(ppt.system_person_type)))='EMP' and
3260 ppf.business_group_id=p_business_group_id and
3261 paf.location_id=hl1.location_id and
3262 hl2.lookup_type=decode(cma_province_count,1,'CA_PROVINCE'
3263 ,2,'CA_CMA') and
3264 hl2.lookup_code=decode(cma_province_count,1,hl1.region_1
3265 ,2,hl1.region_2) and
3266 --pert.segment4 = 'Y' and
3267 pert.request_id=p_request_id and
3268 pert.context=decode(cma_province_count,1,'FORM14'
3269 ,2,'FORM13') and
3270 pert.segment1=decode(cma_province_count,1,'PROVINCE'
3271 ,2,'CMA') and
3272 pert.segment2=hl2.meaning and
3273 paf.assignment_id=pppv.assignment_id and
3274 pppv.change_date = (select max(pppv2.change_date)
3275 from per_pay_proposals_v2 pppv2
3276 where pppv2.assignment_id = paf.assignment_id
3277 and pppv2.approved = 'Y'
3278 and pppv2.change_date <=
3279 decode(substr(paf.employment_category,1,2),
3280 'PT',p_date_tmp_emp,l_year_end)
3281 ) and
3282 trunc(to_number(pppv.proposed_salary)) * ppb.pay_annualization_factor >=
3283 decode(substr(paf.employment_category,1,2),
3284 'FR',v_fr_min_range,v_min_range) and
3285 trunc(to_number(pppv.proposed_salary)) * ppb.pay_annualization_factor <=
3286 decode(substr(paf.employment_category,1,2),
3287 'FR',v_fr_max_range,v_max_range) and
3288 (
3289 (
3290 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
3291 hsck.segment6 is not null and
3292 hsck.segment6 = v_naic_code
3293 )
3294 OR
3295 (
3296 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
3297 hsck.segment6 is null and
3298 hsck.segment1 in (select segment3
3299 from per_ca_ee_report_lines
3300 where request_id = p_request_id and
3301 context = 'FORM13' and
3302 segment1 = 'NAIC' and
3303 segment2 = v_naic_code)
3304 )
3305 )
3306 union all
3307 select
3308 paf.person_id count_total,
3309 'FR' employment_category,
3310 ppf.sex sex,
3311 decode(cma_province_count,1,hl1.region_1,2,hl1.region_2) cma_province
3312 from
3313 per_jobs pj,
3314 per_assignments_f paf,
3315 per_people_f ppf,
3316 per_pay_proposals_v2 pppv,
3317 per_person_types ppt,
3318 hr_locations hl1,
3319 per_ca_ee_report_lines pert,
3320 hr_lookups hl2,
3321 hr_soft_coding_keyflex hsck,
3322 per_pay_bases ppb
3323 where
3324 upper(ltrim(rtrim(pj.job_information_category))) = 'CA' and
3325 pj.job_id=paf.job_id and
3326 paf.primary_flag = 'Y' and
3327 l_year_end between
3328 paf.effective_start_date and
3329 paf.effective_end_date and
3330 (paf.employment_category is null OR
3331 substr(paf.employment_category,1,2) not in ('FR','PR','PT')) and
3332 paf.pay_basis_id = ppb.pay_basis_id and
3333 ppb.business_group_id = p_business_group_id and
3334 paf.person_id=ppf.person_id and
3335 l_year_end between
3336 ppf.effective_start_date and
3337 ppf.effective_end_date and
3338 ppf.person_type_id=ppt.person_type_id and
3339 upper(ltrim(rtrim(ppt.system_person_type)))='EMP' and
3340 ppf.business_group_id=p_business_group_id and
3341 paf.location_id=hl1.location_id and
3342 hl2.lookup_type=decode(cma_province_count,1,'CA_PROVINCE'
3343 ,2,'CA_CMA') and
3344 hl2.lookup_code=decode(cma_province_count,1,hl1.region_1
3345 ,2,hl1.region_2) and
3346 --pert.segment4 = 'Y' and
3347 pert.request_id=p_request_id and
3348 pert.context=decode(cma_province_count,1,'FORM14'
3349 ,2,'FORM13') and
3350 pert.segment1=decode(cma_province_count,1,'PROVINCE'
3354 pppv.change_date = (select max(pppv2.change_date)
3351 ,2,'CMA') and
3352 pert.segment2=hl2.meaning and
3353 paf.assignment_id=pppv.assignment_id and
3355 from per_pay_proposals_v2 pppv2
3356 where pppv2.assignment_id = paf.assignment_id
3357 and pppv2.approved = 'Y'
3358 and pppv2.change_date <= l_year_end
3359 ) and
3360 --to_number(pppv.proposed_salary) >= v_min_range and
3361 --pppv.change_date <= l_year_end and
3362 trunc(to_number(pppv.proposed_salary))* ppb.pay_annualization_factor
3363 >= v_fr_min_range and
3364 trunc(to_number(pppv.proposed_salary))* ppb.pay_annualization_factor
3365 <= v_fr_max_range and
3366 (
3367 (
3368 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
3369 hsck.segment6 is not null and
3370 hsck.segment6 = v_naic_code
3371 )
3372 OR
3373 (
3374 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
3375 hsck.segment6 is null and
3376 hsck.segment1 in (select segment3
3377 from per_ca_ee_report_lines
3378 where request_id = p_request_id and
3379 context = 'FORM13' and
3380 segment1 = 'NAIC' and
3381 segment2 = v_naic_code)
3382 )
3383 )
3384 )
3385 group by employment_category,sex,cma_province
3386 order by cma_province,employment_category,sex;
3387
3388 v_count number(10);
3389 v_sex per_people_f.sex%TYPE;
3390 v_employment_category per_assignments_f.employment_category%TYPE;
3391 prev_employment_category per_assignments_f.employment_category%TYPE;
3392 prev_sex per_people_f.sex%TYPE;
3393 prev_x number := 0;
3394 v_cma_province hr_locations.region_1%TYPE;
3395 prev_naic_code hr_lookups.lookup_code%TYPE;
3396
3397
3398 cursor cur_meaning(cp number) is
3399 select
3400 meaning from hr_lookups
3401 where
3402 upper(ltrim(rtrim(lookup_type)))=decode(cp,1,'CA_PROVINCE'
3403 ,2,'CA_CMA') and
3404 upper(ltrim(rtrim(lookup_code)))=upper(ltrim(rtrim(v_cma_province)));
3405
3406 v_meaning hr_lookups.meaning%TYPE;
3407 prev_meaning hr_lookups.meaning%TYPE;
3408
3409 cursor cur_count(cma_province_ct number,
3410 count number,
3411 desig number) is
3412 select
3413 count(distinct person_id) count,
3414 employment_category employment_category,
3415 sex sex,
3416 cma_province cma_province
3417 from
3418 (
3419 select
3420 paf.person_id person_id,
3421 substr(paf.employment_category,1,2) employment_category,
3422 ppf.sex sex,
3423 decode(cma_province_ct,1,hl1.region_1,2,hl1.region_2) cma_province
3424 from
3425 per_jobs pj,
3426 per_assignments_f paf,
3427 per_people_f ppf,
3428 per_pay_proposals_v2 pppv,
3429 per_person_types ppt,
3430 hr_locations hl1,
3431 per_ca_ee_report_lines pert,
3432 hr_lookups hl2,
3433 hr_soft_coding_keyflex hsck,
3434 per_pay_bases ppb
3435 where
3436 upper(ltrim(rtrim(pj.job_information_category))) = 'CA' and
3437 pj.job_id=paf.job_id and
3438 paf.primary_flag = 'Y' and
3439 decode(paf.employment_category,'PT',p_date_tmp_emp,l_year_end) between
3440 paf.effective_start_date and
3441 paf.effective_end_date and
3442 paf.employment_category is not null and
3443 substr(paf.employment_category,1,2) in ('FR','PR','PT') and
3444 paf.person_id=ppf.person_id and
3445 decode(paf.employment_category,'PT',p_date_tmp_emp,l_year_end) between
3446 ppf.effective_start_date and
3447 ppf.effective_end_date and
3448 paf.pay_basis_id = ppb.pay_basis_id and
3449 ppb.business_group_id = p_business_group_id and
3450 ppf.person_type_id=ppt.person_type_id and
3451 upper(ltrim(rtrim(ppt.system_person_type)))='EMP' and
3452 ppf.business_group_id=p_business_group_id and
3453 paf.location_id=hl1.location_id and
3454 hl2.lookup_type=decode(cma_province_ct,1,'CA_PROVINCE'
3455 ,2,'CA_CMA') and
3456 hl2.lookup_code=decode(cma_province_ct,1,hl1.region_1
3457 ,2,hl1.region_2) and
3458 --pert.segment4 = 'Y' and
3459 pert.request_id=p_request_id and
3460 pert.context=decode(cma_province_ct,1,'FORM14'
3461 ,2,'FORM13') and
3462 pert.segment1=decode(cma_province_ct,1,'PROVINCE'
3463 ,2,'CMA') and
3464 pert.segment2=hl2.meaning and
3465 decode(desig,1,per_information5,
3466 2,per_information6,
3467 3,per_information7)='Y' and
3468 substr(NVL(paf.employment_category,'FR'),1,2)=v_employment_category and
3469 paf.assignment_id=pppv.assignment_id and
3470 pppv.change_date = (select max(pppv2.change_date)
3471 from per_pay_proposals_v2 pppv2
3472 where pppv2.assignment_id = paf.assignment_id
3473 and pppv2.approved = 'Y'
3477 ) and
3474 and pppv2.change_date <=
3475 decode(substr(paf.employment_category,1,2),
3476 'PT',p_date_tmp_emp,l_year_end)
3478 trunc(to_number(pppv.proposed_salary)) * ppb.pay_annualization_factor >=
3479 decode(substr(paf.employment_category,1,2),
3480 'FR',v_fr_min_range,v_min_range) and
3481 trunc(to_number(pppv.proposed_salary)) * ppb.pay_annualization_factor <=
3482 decode(substr(paf.employment_category,1,2),
3483 'FR',v_fr_max_range,v_max_range) and
3484 (
3485 (
3486 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
3487 hsck.segment6 is not null and
3488 hsck.segment6 = v_naic_code
3489 )
3490 OR
3491 (
3492 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
3493 hsck.segment6 is null and
3494 hsck.segment1 in (select segment3
3495 from per_ca_ee_report_lines
3496 where request_id = p_request_id and
3497 context = 'FORM13' and
3498 segment1 = 'NAIC' and
3499 segment2 = v_naic_code)
3500 )
3501 )
3502 union all
3503 select
3504 paf.person_id person_id,
3505 'FR' employment_category,
3506 ppf.sex sex,
3507 decode(cma_province_ct,1,hl1.region_1,2,hl1.region_2) cma_province
3508 from
3509 per_jobs pj,
3510 per_assignments_f paf,
3511 per_people_f ppf,
3512 per_pay_proposals_v2 pppv,
3513 per_person_types ppt,
3514 hr_locations hl1,
3515 per_ca_ee_report_lines pert,
3516 hr_lookups hl2,
3517 hr_soft_coding_keyflex hsck,
3518 per_pay_bases ppb
3519 where
3520 upper(ltrim(rtrim(pj.job_information_category))) = 'CA' and
3521 pj.job_id=paf.job_id and
3522 paf.primary_flag = 'Y' and
3523 l_year_end between
3524 paf.effective_start_date and
3525 paf.effective_end_date and
3526 (paf.employment_category is null OR
3527 substr(paf.employment_category,1,2) not in ('FR','PR','PT')) and
3528 paf.person_id=ppf.person_id and
3529 l_year_end between
3530 paf.effective_start_date and
3531 paf.effective_end_date and
3532 ppf.person_type_id=ppt.person_type_id and
3533 upper(ltrim(rtrim(ppt.system_person_type)))='EMP' and
3534 ppf.business_group_id=p_business_group_id and
3535 paf.location_id=hl1.location_id and
3536 hl2.lookup_type=decode(cma_province_ct,1,'CA_PROVINCE'
3537 ,2,'CA_CMA') and
3538 hl2.lookup_code=decode(cma_province_ct,1,hl1.region_1
3539 ,2,hl1.region_2) and
3540 --pert.segment4 = 'Y' and
3541 pert.request_id=p_request_id and
3542 pert.context=decode(cma_province_ct,1,'FORM14'
3543 ,2,'FORM13') and
3544 pert.segment1=decode(cma_province_ct,1,'PROVINCE'
3545 ,2,'CMA') and
3546 pert.segment2=hl2.meaning and
3547 decode(desig,1,per_information5,
3548 2,per_information6,
3549 3,per_information7)='Y' and
3550 --substr(NVL(paf.employment_category,'FR'),1,2)=v_employment_category and
3551 paf.pay_basis_id = ppb.pay_basis_id and
3552 ppb.business_group_id = p_business_group_id and
3553 paf.assignment_id=pppv.assignment_id and
3554 pppv.change_date = (select max(pppv2.change_date)
3555 from per_pay_proposals_v2 pppv2
3556 where pppv2.assignment_id = paf.assignment_id
3557 and pppv2.approved = 'Y'
3558 and pppv2.change_date <= l_year_end
3559 ) and
3560 trunc(to_number(pppv.proposed_salary))
3561 * ppb.pay_annualization_factor >= v_fr_min_range and
3562 trunc(to_number(pppv.proposed_salary))
3563 * ppb.pay_annualization_factor <= v_fr_max_range and
3564 (
3565 (
3566 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
3567 hsck.segment6 is not null and
3568 hsck.segment6 = v_naic_code
3569 )
3570 OR
3571 (
3572 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
3573 hsck.segment6 is null and
3574 hsck.segment1 in (select segment3
3575 from per_ca_ee_report_lines
3576 where request_id = p_request_id and
3577 context = 'FORM13' and
3578 segment1 = 'NAIC' and
3579 segment2 = v_naic_code)
3580 )
3581 )
3582 )
3583 group by employment_category,sex,cma_province
3584 order by employment_category,sex,cma_province;
3585
3586 cursor cur_notfound(range varchar2,
3587 pc number,
3588 p_category varchar2) is
3589 select
3590 decode(pc,1,'PROVINCE','CMA') provcma,
3591 segment2 provcma_name,
3595 max_min_range
3592 p_category emp_category,
3593 decode(p_category,'FR',v_fr_min_range|| ' - ' || v_fr_max_range,
3594 v_min_range || ' - ' || v_max_range)
3596
3597 from
3598 per_ca_ee_report_lines
3599 where
3600 request_id = p_request_id and
3601 context=decode(pc,1,'FORM14','FORM13') and
3602 segment1 = decode(pc,1,'PROVINCE','CMA') and
3603 segment3 <> '0'
3604 minus
3605 select
3606 segment1,
3607 segment2,
3608 segment4,
3609 segment3
3610 from
3611 per_ca_ee_report_lines
3612 where
3613 request_id = p_request_id and
3614 context = 'FORM3' and
3615 segment1 = decode(pc,1,'PROVINCE','CMA') and
3616 segment21 = v_naic_code;
3617
3618 cursor cur_count_national is
3619 select
3620 segment3,
3621 segment4,
3622 sum(to_number(segment5)) segment5,
3623 sum(to_number(segment6)) segment6,
3624 sum(to_number(segment7)) segment7,
3625 sum(to_number(segment8)) segment8,
3626 sum(to_number(segment9)) segment9,
3627 sum(to_number(segment10)) segment10,
3628 sum(to_number(segment11)) segment11,
3629 sum(to_number(segment12)) segment12,
3630 sum(to_number(segment13)) segment13,
3631 sum(to_number(segment14)) segment14,
3632 sum(to_number(segment15)) segment15,
3633 sum(to_number(segment16)) segment16
3634 from
3635 per_ca_ee_report_lines
3636 where
3637 request_id = p_request_id and
3638 context = 'FORM3' and
3639 segment1 = 'PROVINCE' and
3640 segment21 = v_naic_code
3641 group by segment3,segment4;
3642
3643 pc_count number;
3644 emp_cat varchar2(2);
3645
3646 begin
3647
3648 hr_utility.trace('Form3 starts here !!!!!');
3649
3650 for naic in cur_naic loop
3651
3652 v_naic_code := naic.naic_code;
3653
3654 for i in 1..2 loop
3655 for x in 1..14 loop
3656
3657 if x = 1 then
3658
3659 v_min_range := 0;
3660 v_max_range := 4999;
3661
3662 v_fr_min_range := 0;
3663 v_fr_max_range := 14999;
3664
3665 elsif x = 2 then
3666
3667 v_min_range := 5000;
3668 v_max_range := 7499;
3669
3670 v_fr_min_range := 15000;
3671 v_fr_max_range := 19999;
3672
3673 elsif x = 3 then
3674
3675 v_min_range := 7500;
3676 v_max_range := 9999;
3677
3678 v_fr_min_range := 20000;
3679 v_fr_max_range := 24999;
3680
3681 elsif x = 4 then
3682
3683 v_min_range := 10000;
3684 v_max_range := 12499;
3685
3686 v_fr_min_range := 25000;
3687 v_fr_max_range := 29999;
3688
3689 elsif x = 5 then
3690
3691 v_min_range := 12500;
3692 v_max_range := 14999;
3693
3694 v_fr_min_range := 30000;
3695 v_fr_max_range := 34999;
3696
3697 elsif x = 6 then
3698
3699 v_min_range := 15000;
3700 v_max_range := 17499;
3701
3702 v_fr_min_range := 35000;
3703 v_fr_max_range := 37499;
3704
3705 elsif x = 7 then
3706
3707 v_min_range := 17500;
3708 v_max_range := 19999;
3709
3710 v_fr_min_range := 37500;
3711 v_fr_max_range := 39999;
3712
3713 elsif x = 8 then
3714
3715 v_min_range := 20000;
3716 v_max_range := 22499;
3717
3718 v_fr_min_range := 40000;
3719 v_fr_max_range := 44999;
3720
3721 elsif x = 9 then
3722
3723 v_min_range := 22500;
3724 v_max_range := 24999;
3725
3726 v_fr_min_range := 45000;
3727 v_fr_max_range := 49999;
3728
3729 elsif x = 10 then
3730
3731 v_min_range := 25000;
3732 v_max_range := 29999;
3733
3734 v_fr_min_range := 50000;
3735 v_fr_max_range := 59999;
3736
3737 elsif x = 11 then
3738
3739 v_min_range := 30000;
3740 v_max_range := 34499;
3741
3742 v_fr_min_range := 60000;
3743 v_fr_max_range := 69999;
3744
3745 elsif x = 12 then
3746
3747 v_min_range := 35000;
3748 v_max_range := 39999;
3749
3750 v_fr_min_range := 70000;
3751 v_fr_max_range := 84999;
3752
3753 elsif x = 13 then
3754
3755 v_min_range := 40000;
3756 v_max_range := 49999;
3757
3758 v_fr_min_range := 85000;
3759 v_fr_max_range := 99999;
3760
3761 elsif x = 14 then
3762
3763 v_min_range := 50000;
3764 v_max_range := 9999999;
3765
3766 v_fr_min_range := 100000;
3767 v_fr_max_range := 9999999;
3768
3769 end if;
3770
3771 hr_utility.trace('v_min_range = '||to_char(v_min_range));
3772 hr_utility.trace('v_max_range = '||to_char(v_max_range));
3773 hr_utility.trace('cur_count_total = ');
3774
3775 for l in cur_count_total(i,x) loop
3776
3777 v_count := l.count_total;
3778 v_sex := l.sex;
3779 v_employment_category := l.employment_category;
3780 v_cma_province := l.cma_province;
3781
3785 hr_utility.trace('v_cma_province = '|| v_cma_province );
3782 hr_utility.trace('v_count = ' || to_char(v_count));
3783 hr_utility.trace('v_sex = '|| v_sex);
3784 hr_utility.trace('v_employment_category = ' || v_employment_category);
3786
3787 open cur_meaning(i);
3788 fetch cur_meaning into v_meaning;
3789 close cur_meaning;
3790
3791 if
3792 (
3793 (ltrim(rtrim(prev_meaning)) <> ltrim(rtrim(v_meaning))) or
3794 (ltrim(rtrim(prev_employment_category)) <>
3795 ltrim(rtrim(v_employment_category))) or
3796 (ltrim(rtrim(prev_naic_code)) <> ltrim(rtrim(v_naic_code))) or
3797 (prev_x <> x)
3798 ) then
3799
3800 hr_utility.trace('v_meaning = '|| v_meaning );
3801
3802 per_ca_ee_extract_pkg.k := per_ca_ee_extract_pkg.k + 1;
3803
3804 insert into per_ca_ee_report_lines
3805 ( request_id,
3806 line_number,
3807 context,
3808 segment1,
3809 segment2,
3810 segment3,
3811 segment4,
3812 segment5,
3813 segment6,
3814 segment7,
3815 segment8,
3816 segment9,
3817 segment10,
3818 segment11,
3819 segment12,
3820 segment13,
3821 segment14,
3822 segment15,
3823 segment16,
3824 segment21) values
3825 ( p_request_id,
3826 per_ca_ee_extract_pkg.k,
3827 'FORM3',
3828 decode(i,1,'PROVINCE',
3829 2,'CMA'),
3830 v_meaning,
3831 decode(v_employment_category,'FR',
3832 v_fr_min_range||' - '||v_fr_max_range,
3833 v_min_range||' - '||v_max_range),
3834 v_employment_category,
3835 nvl(v_count,0),
3836 decode(v_sex,'F',v_count,0),
3837 decode(v_sex,'M',v_count,0),
3838 0,
3839 0,
3840 0,
3841 0,
3842 0,
3843 0,
3844 0,
3845 0,
3846 0,
3847 v_naic_code) ;
3848
3849 else
3850 if prev_meaning = v_meaning and
3851 prev_employment_category = v_employment_category and
3852 prev_naic_code = v_naic_code and
3853 prev_x = x and
3854 prev_sex <> v_sex then
3855
3856 if v_sex = 'M' then
3857 update per_ca_ee_report_lines set
3858 segment5 = segment5 + nvl(v_count,0),
3859 segment7 = nvl(v_count,0)
3860 where
3861 request_id=p_request_id and
3862 line_number=per_ca_ee_extract_pkg.k and
3863 context = 'FORM3' and
3864 segment1 = decode(i,1,'PROVINCE',2,'CMA') and
3865 segment2 = v_meaning and
3866 segment3 = decode(v_employment_category,'FR',
3867 v_fr_min_range|| ' - '||v_fr_max_range,
3868 v_min_range|| ' - '||v_max_range) and
3869 segment4 = v_employment_category and
3870 segment21 = v_naic_code;
3871
3872 elsif v_sex = 'F' then
3873
3874 update per_ca_ee_report_lines set
3875 segment5=segment5 + nvl(v_count,0),
3876 segment6=nvl(v_count,0)
3877 where
3878 request_id=p_request_id and
3879 line_number=per_ca_ee_extract_pkg.k and
3880 context='FORM3' and
3881 segment1=decode(i,1,'PROVINCE',2,'CMA') and
3882 segment2=v_meaning and
3883 segment3=decode(v_employment_category,'FR',
3884 v_fr_min_range|| ' - '||v_fr_max_range ,
3885 v_min_range|| ' - '||v_max_range) and
3886 segment4=v_employment_category and
3887 segment21 = v_naic_code;
3888
3889 end if;
3890 end if;
3891 end if;
3892
3893 prev_employment_category := v_employment_category;
3894 prev_sex := v_sex;
3895 prev_x := x;
3896 prev_meaning := v_meaning;
3897 prev_naic_code := v_naic_code;
3898
3899 end loop;
3900
3901
3902 ---------------------------------
3903 -- Updation designated Group --
3904 ---------------------------------
3905
3906 hr_utility.trace('Form3: v_fr_min_range: ' || to_char(v_fr_min_range));
3907 hr_utility.trace('Form3: v_fr_max_range: ' || to_char(v_fr_max_range));
3908
3909 for k in 1..3 loop
3910
3911 for l in cur_count(i,x,k) loop
3912
3913 hr_utility.trace('Form3: Updation Designated Group');
3914
3915 v_cma_province := l.cma_province;
3916 v_employment_category := l.employment_category;
3917
3918 hr_utility.trace('Form3: v_meaning: ' || v_meaning);
3919 hr_utility.trace('Form3: v_cma_province: ' || v_cma_province);
3920 hr_utility.trace('Form3: v_employment_category: '
3921 || v_employment_category);
3922 hr_utility.trace('Form3: v_fr_min_range: ' || to_char(v_fr_min_range));
3923 hr_utility.trace('Form3: v_fr_max_range: ' || to_char(v_fr_max_range));
3924
3925 open cur_meaning(i);
3926 fetch cur_meaning into v_meaning;
3927 close cur_meaning;
3928
3929 if k = 1 then
3930
3934 update per_ca_ee_report_lines set
3931 hr_utility.trace('Form3: Updation Designated Grp: k = 1. ');
3932 if l.sex = 'F' then
3933
3935 segment8=nvl(segment8,0) + nvl(l.count,0),
3936 segment9=nvl(l.count,0)
3937 where
3938 request_id = p_request_id and
3939 context = 'FORM3' and
3940 ltrim(rtrim(segment1)) = decode(i,1,'PROVINCE',2,'CMA') and
3941 ltrim(rtrim(segment2)) = v_meaning and
3942 ltrim(rtrim(segment3)) = decode(v_employment_category,'FR',
3943 v_fr_min_range|| ' - '||v_fr_max_range,
3944 v_min_range|| ' - ' ||v_max_range) and
3945 upper(ltrim(rtrim(segment4))) =
3946 upper(ltrim(rtrim(v_employment_category))) and
3947 segment21 = v_naic_code;
3948
3949 elsif l.sex = 'M' then
3950
3951 update per_ca_ee_report_lines set
3952 segment8 = nvl(segment8,0) + nvl(l.count,0),
3953 segment10 = nvl(l.count,0)
3954 where
3955 request_id = p_request_id and
3956 context = 'FORM3' and
3957 ltrim(rtrim(segment1)) = decode(i,1,'PROVINCE',2,'CMA') and
3958 ltrim(rtrim(segment2)) = v_meaning and
3959 rtrim(ltrim(segment3)) = decode(v_employment_category,'FR',
3960 v_fr_min_range|| ' - '||v_fr_max_range,
3961 v_min_range|| ' - ' ||v_max_range) and
3962 upper(ltrim(rtrim(segment4)))
3963 = upper(ltrim(rtrim(v_employment_category))) and
3964 segment21 = v_naic_code;
3965
3966 end if;
3967
3968 elsif k = 2 then
3969
3970 hr_utility.trace('Form3: Updation Designated Grp: k = 2. ');
3971
3972 if l.sex = 'F' then
3973
3974 update per_ca_ee_report_lines set
3975 segment11=nvl(segment11,0) + nvl(l.count,0),
3976 segment12=nvl(l.count,0)
3977 where
3978 request_id=p_request_id and
3979 context='FORM3' and
3980 ltrim(rtrim(segment1))=decode(i,1,'PROVINCE',2,'CMA') and
3981 ltrim(rtrim(segment2))=v_meaning and
3982 ltrim(rtrim(segment3))=decode(v_employment_category,'FR',
3983 v_fr_min_range|| ' - '||v_fr_max_range,
3984 v_min_range|| ' - ' ||v_max_range) and
3985 upper(ltrim(rtrim(segment4)))
3986 = upper(ltrim(rtrim(v_employment_category))) and
3987 segment21 = v_naic_code;
3988
3989 else
3990
3991 update per_ca_ee_report_lines set
3992 segment11=nvl(segment11,0) + nvl(l.count,0),
3993 segment13=nvl(l.count,0)
3994 where
3995 request_id=p_request_id and
3996 context='FORM3' and
3997 ltrim(rtrim(segment1))=decode(i,1,'PROVINCE',2,'CMA') and
3998 ltrim(rtrim(segment2))=v_meaning and
3999 ltrim(rtrim(segment3))= decode(v_employment_category,'FR',
4000 v_fr_min_range|| ' - '||v_fr_max_range,
4001 v_min_range|| ' - ' ||v_max_range) and
4002 upper(ltrim(rtrim(segment4)))
4003 = upper(ltrim(rtrim(v_employment_category))) and
4004 segment21 = v_naic_code;
4005
4006 end if;
4007
4008 elsif k = 3 then
4009
4010 hr_utility.trace('Form3: Updation Designated Grp: k = 3. ');
4011
4012 if l.sex = 'F' then
4013
4014 hr_utility.trace('Form3: Updation Designated Grp: k = 3. F ');
4015
4016 update per_ca_ee_report_lines set
4017 segment14=nvl(segment14,0) + nvl(l.count,0),
4018 segment16=nvl(l.count,0)
4019 where
4020 request_id=p_request_id and
4021 context='FORM3' and
4022 ltrim(rtrim(segment1))=decode(i,1,'PROVINCE',2,'CMA') and
4023 ltrim(rtrim(segment2))=v_meaning and
4024 ltrim(rtrim(segment3))= decode(v_employment_category,'FR',
4025 v_fr_min_range|| ' - '||v_fr_max_range,
4026 v_min_range|| ' - ' ||v_max_range) and
4027 upper(ltrim(rtrim(segment4)))
4028 =upper(ltrim(rtrim(v_employment_category))) and
4029 segment21 = v_naic_code;
4030
4031 else
4032
4033 hr_utility.trace('Form3: Updation Designated Grp: k = 3. M ');
4034 --hr_utility.trace('Form3: v_meaning: ' || v_meaning);
4035 --hr_utility.trace('Form3: v_cma_province: ' || v_cma_province);
4036 --hr_utility.trace('Form3: v_employment_category: '
4037 -- || v_employment_category);
4038 --hr_utility.trace('Form3: v_fr_min_range: ' || to_char(v_fr_min_range));
4039 --hr_utility.trace('Form3: v_fr_max_range: ' || to_char(v_fr_max_range));
4040
4041 update per_ca_ee_report_lines set
4042 segment14=nvl(segment14,0) + nvl(l.count,0),
4043 segment15=nvl(l.count,0)
4044 where
4048 ltrim(rtrim(segment2)) = v_meaning and
4045 request_id=p_request_id and
4046 context='FORM3' and
4047 ltrim(rtrim(segment1)) = decode(i,1,'PROVINCE',2,'CMA') and
4049 ltrim(rtrim(segment3)) = decode(v_employment_category,'FR',
4050 v_fr_min_range|| ' - '||v_fr_max_range,
4051 v_min_range|| ' - ' ||v_max_range) and
4052 upper(ltrim(rtrim(segment4)))
4053 =upper(ltrim(rtrim(v_employment_category))) and
4054 segment21 = v_naic_code;
4055 end if;
4056
4057 end if;
4058 end loop;
4059 end loop;
4060
4061 end loop;
4062 end loop;
4063
4064
4065 for x in 1..14 loop
4066
4067 if x = 1 then
4068
4069 v_min_range := 0;
4070 v_max_range := 4999;
4071
4072 v_fr_min_range := 0;
4073 v_fr_max_range := 14999;
4074
4075 elsif x = 2 then
4076
4077 v_min_range := 5000;
4078 v_max_range := 7499;
4079
4080 v_fr_min_range := 15000;
4081 v_fr_max_range := 19999;
4082
4083 elsif x = 3 then
4084
4085 v_min_range := 7500;
4086 v_max_range := 9999;
4087
4088 v_fr_min_range := 20000;
4089 v_fr_max_range := 24999;
4090
4091 elsif x = 4 then
4092
4093 v_min_range := 10000;
4094 v_max_range := 12499;
4095
4096 v_fr_min_range := 25000;
4097 v_fr_max_range := 29999;
4098
4099 elsif x = 5 then
4100
4101 v_min_range := 12500;
4102 v_max_range := 14999;
4103
4104 v_fr_min_range := 30000;
4105 v_fr_max_range := 34999;
4106
4107 elsif x = 6 then
4108
4109 v_min_range := 15000;
4110 v_max_range := 17499;
4111
4112 v_fr_min_range := 35000;
4113 v_fr_max_range := 37499;
4114
4115 elsif x = 7 then
4116
4117 v_min_range := 17500;
4118 v_max_range := 19999;
4119
4120 v_fr_min_range := 37500;
4121 v_fr_max_range := 39999;
4122
4123 elsif x = 8 then
4124
4125 v_min_range := 20000;
4126 v_max_range := 22499;
4127
4128 v_fr_min_range := 40000;
4129 v_fr_max_range := 44999;
4130
4131 elsif x = 9 then
4132
4133 v_min_range := 22500;
4134 v_max_range := 24999;
4135
4136 v_fr_min_range := 45000;
4137 v_fr_max_range := 49999;
4138
4139 elsif x = 10 then
4140
4141 v_min_range := 25000;
4142 v_max_range := 29999;
4143
4144 v_fr_min_range := 50000;
4145 v_fr_max_range := 59999;
4146
4147 elsif x = 11 then
4148
4149 v_min_range := 30000;
4150 v_max_range := 34499;
4151
4152 v_fr_min_range := 60000;
4153 v_fr_max_range := 69999;
4154
4155 elsif x = 12 then
4156
4157 v_min_range := 35000;
4158 v_max_range := 39999;
4159
4160 v_fr_min_range := 70000;
4161 v_fr_max_range := 84999;
4162
4163 elsif x = 13 then
4164
4165 v_min_range := 40000;
4166 v_max_range := 49999;
4167
4168 v_fr_min_range := 85000;
4169 v_fr_max_range := 99999;
4170
4171 elsif x = 14 then
4172
4173 v_min_range := 50000;
4174 v_max_range := 9999999;
4175
4176 v_fr_min_range := 100000;
4177 v_fr_max_range := 9999999;
4178
4179 end if;
4180
4181 for l_pc_count in 1..2 loop
4182
4183 if l_pc_count = 1 then
4184 pc_count := 1;
4185 else
4186 pc_count := 2;
4187 end if;
4188
4189 for l_emp_cat in 1..3 loop
4190
4191 if l_emp_cat = 1 then
4192 emp_cat := 'FR';
4193 elsif l_emp_cat = 2 then
4194 emp_cat := 'PR';
4195 elsif l_emp_cat = 3 then
4196 emp_cat := 'PT';
4197 end if;
4198
4199 for l in cur_notfound(x,
4200 pc_count,
4201 emp_cat)
4202 loop
4203
4204 per_ca_ee_extract_pkg.k := per_ca_ee_extract_pkg.k + 1;
4205
4206 insert into per_ca_ee_report_lines
4207 ( request_id,
4208 line_number,
4209 context,
4210 segment1,
4211 segment2,
4212 segment3,
4213 segment4,
4214 segment5,
4215 segment6,
4216 segment7,
4217 segment8,
4218 segment9,
4219 segment10,
4220 segment11,
4221 segment12,
4222 segment13,
4223 segment14,
4224 segment15,
4225 segment16,
4226 segment21) values
4227 ( p_request_id,
4228 per_ca_ee_extract_pkg.k,
4229 'FORM3',
4230 decode(pc_count,1,'PROVINCE','CMA'),
4231 l.provcma_name,
4232 decode(emp_cat,'FR',v_fr_min_range||' - '||v_fr_max_range,
4233 v_min_range||' - '||v_max_range),
4234 emp_cat,
4235 '0',
4236 '0',
4237 '0',
4238 '0',
4239 '0',
4240 '0',
4241 '0',
4242 '0',
4243 '0',
4244 '0',
4245 '0',
4246 '0',
4247 v_naic_code);
4251 end loop; --End loop emp_cat.
4248
4249 end loop;
4250
4252
4253 end loop; -- End loop pc_count
4254 end loop;
4255
4256 for count_national in cur_count_national loop
4257
4258 hr_utility.trace('Form3: cur_count_national. ');
4259
4260 insert into per_ca_ee_report_lines
4261 (request_id,
4262 line_number,
4263 context,
4264 segment1,
4265 segment2,
4266 segment3,
4267 segment4,
4268 segment5,
4269 segment6,
4270 segment7,
4271 segment8,
4272 segment9,
4273 segment10,
4274 segment11,
4275 segment12,
4276 segment13,
4277 segment14,
4278 segment15,
4279 segment21) values
4280 ( p_request_id,
4281 per_ca_ee_extract_pkg.k,
4282 'FORM3',
4283 'NATIONAL',
4284 count_national.segment3,
4285 count_national.segment4,
4286 count_national.segment5,
4287 count_national.segment6,
4288 count_national.segment7,
4289 count_national.segment8,
4290 count_national.segment9,
4291 count_national.segment10,
4292 count_national.segment11,
4293 count_national.segment12,
4294 count_national.segment13,
4295 count_national.segment14,
4296 count_national.segment15,
4297 count_national.segment16,
4298 v_naic_code);
4299
4300 end loop; --End of loop cur_national_count
4301
4302 prev_naic_code := v_naic_code;
4303
4304 end loop; -- End loop for cur_naic
4305
4306
4307 return 1;
4308 end;
4309
4310 end form3;
4311
4312 function form4(p_business_group_id in number,
4313 p_request_id in number,
4314 p_year in varchar2,
4315 p_date_tmp_emp in date) return number is
4316
4317 l_year_start date;
4318 l_year_end date;
4319
4320 begin
4321
4322 l_year_start := trunc(to_date(p_year,'YYYY'),'Y');
4323 l_year_end := add_months(trunc(to_date(p_year,'YYYY'),'Y'), 12) -1;
4324
4325 declare
4326
4327 cursor cur_naic is
4328 select
4329 pert.segment4 naic_code
4330 from
4331 per_ca_ee_report_lines pert
4332 where
4333 pert.request_id = p_request_id and
4334 pert.context = 'FORM12';
4335
4336 v_naic_code hr_lookups.lookup_code%TYPE;
4337
4338 cursor cur_hired_total is
4339 select
4340 count(distinct count_total) count_total,
4341 meaning meaning,
4342 sex sex,
4343 employment_category employment_category,
4344 province province
4345 from
4346 (
4347 select
4348 paf.person_id count_total,
4349 hl.meaning meaning,
4350 ppf.sex sex,
4351 substr(employment_category,1,2) employment_category,
4352 hl1.region_1 province
4353 from
4354 hr_lookups hl,
4355 per_jobs pj,
4356 per_assignments_f paf,
4357 per_people_f ppf,
4358 per_person_types ppt,
4359 hr_locations hl1,
4360 per_ca_ee_report_lines pert,
4361 hr_lookups hl2,
4362 hr_soft_coding_keyflex hsck
4363 where
4364 hl.lookup_type='EEOG' and
4365 upper(ltrim(rtrim(hl.lookup_code)))
4366 = upper(ltrim(rtrim(pj.job_information1))) and
4367 upper(ltrim(rtrim(pj.job_information_category))) = 'CA' and
4368 pj.job_id=paf.job_id and
4369 paf.primary_flag = 'Y' and
4370 --decode(paf.employment_category,'PT',p_date_tmp_emp,l_year_end) between
4371 -- paf.effective_start_date and
4372 -- paf.effective_end_date and
4373 --paf.effective_start_date < l_year_end and
4374 --paf.effective_end_date > l_year_start and
4375 ppf.start_date between
4376 paf.effective_start_date and
4377 paf.effective_end_date and
4378 paf.employment_category is not null and
4379 substr(employment_category,1,2) in ('FR','PR','PT') and
4380 paf.person_id=ppf.person_id and
4381 --decode(paf.employment_category,'PT',p_date_tmp_emp,l_year_end) between
4382 -- ppf.effective_start_date and
4383 -- ppf.effective_end_date and
4384 ppf.effective_start_date < l_year_end and
4385 ppf.effective_end_date > l_year_start and
4386 ppf.start_date between l_year_start and
4387 l_year_end and
4388 ppf.person_type_id=ppt.person_type_id and
4389 upper(ltrim(rtrim(ppt.system_person_type)))='EMP' and
4390 ppf.business_group_id=p_business_group_id and
4391 paf.location_id=hl1.location_id and
4392 hl1.region_1=hl2.lookup_code and
4393 hl2.lookup_type='CA_PROVINCE' and
4394 pert.request_id=p_request_id and
4395 hl2.meaning=pert.segment2 and
4396 --pert.segment4 = 'Y' and
4397 pert.context='FORM14' and
4398 pert.segment1='PROVINCE' and
4399 (
4400 (
4401 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
4405 OR
4402 hsck.segment6 is not null and
4403 hsck.segment6 = v_naic_code
4404 )
4406 (
4407 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
4408 hsck.segment6 is null and
4409 hsck.segment1 in (select segment3
4410 from per_ca_ee_report_lines
4411 where request_id = p_request_id and
4412 context = 'FORM13' and
4413 segment1 = 'NAIC' and
4414 segment2 = v_naic_code)
4415 )
4416 ) and
4417 exists
4418 (
4419 select 'X'
4420 from per_pay_proposals_v2 pppv
4421 where
4422 pppv.assignment_id = paf.assignment_id and
4423 pppv.approved = 'Y' and
4424 pppv.change_date <= l_year_end
4425 )
4426 union all
4427 select
4428 paf.person_id count_total,
4429 hl.meaning meaning,
4430 ppf.sex sex,
4431 'FR' employment_category,
4432 hl1.region_1 province
4433 from
4434 hr_lookups hl,
4435 per_jobs pj,
4436 per_assignments_f paf,
4437 per_people_f ppf,
4438 per_person_types ppt,
4439 hr_locations hl1,
4440 per_ca_ee_report_lines pert,
4441 hr_lookups hl2,
4442 hr_soft_coding_keyflex hsck
4443 where
4444 hl.lookup_type='EEOG' and
4445 upper(ltrim(rtrim(hl.lookup_code)))
4446 =upper(ltrim(rtrim(pj.job_information1))) and
4447 upper(ltrim(rtrim(pj.job_information_category))) = 'CA' and
4448 pj.job_id=paf.job_id and
4449 paf.primary_flag = 'Y' and
4450 --l_year_end between
4451 -- paf.effective_start_date and
4452 -- paf.effective_end_date and
4453 --paf.effective_start_date < l_year_end and
4454 --paf.effective_end_date > l_year_start and
4455 ppf.start_date between
4456 paf.effective_start_date and
4457 paf.effective_end_date and
4458 (paf.employment_category is null OR
4459 substr(paf.employment_category,1,2) not in ('FR','PR','PT')) and
4460 paf.person_id=ppf.person_id and
4461 --l_year_end between
4462 -- ppf.effective_start_date and
4463 -- ppf.effective_end_date and
4464 ppf.effective_start_date < l_year_end and
4465 ppf.effective_end_date > l_year_start and
4466 ppf.start_date between l_year_start and
4467 l_year_end and
4468 ppf.person_type_id=ppt.person_type_id and
4469 upper(ltrim(rtrim(ppt.system_person_type)))='EMP' and
4470 ppf.business_group_id=p_business_group_id and
4471 paf.location_id=hl1.location_id and
4472 hl1.region_1=hl2.lookup_code and
4473 hl2.lookup_type='CA_PROVINCE' and
4474 pert.request_id=p_request_id and
4475 hl2.meaning=pert.segment2 and
4476 --pert.segment4 = 'Y' and
4477 pert.context='FORM14' and
4478 pert.segment1='PROVINCE' and
4479 (
4480 (
4481 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
4482 hsck.segment6 is not null and
4483 hsck.segment6 = v_naic_code
4484 )
4485 OR
4486 (
4487 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
4488 hsck.segment6 is null and
4489 hsck.segment1 in (select segment3
4490 from per_ca_ee_report_lines
4491 where request_id = p_request_id and
4492 context = 'FORM13' and
4493 segment1 = 'NAIC' and
4494 segment2 = v_naic_code)
4495 )
4496 ) and
4497 exists
4498 (
4499 select 'X'
4500 from per_pay_proposals_v2 pppv
4501 where
4502 pppv.assignment_id = paf.assignment_id and
4503 pppv.approved = 'Y' and
4504 pppv.change_date <= l_year_end
4505 ) -- End of Exists
4506 )
4507 group by province,meaning,employment_category,sex
4508 order by province,meaning,employment_category,sex;
4509
4510 v_count number(10);
4511 v_meaning hr_lookups.meaning%TYPE;
4512 v_employment_category per_assignments_f.employment_category%TYPE;
4513 v_sex per_people_f.sex%TYPE;
4514 v_province hr_locations.region_1%TYPE;
4515 prev_meaning hr_lookups.meaning%TYPE := 'test';
4516 prev_employment_category per_assignments_f.employment_category%TYPE := 'test';
4517 prev_sex per_people_f.sex%TYPE := 'test';
4518 prev_naic_code hr_lookups.lookup_code%TYPE;
4519
4520 cursor cur_meaning is
4521 select
4522 meaning
4523 from
4524 hr_lookups
4525 where
4526 upper(ltrim(rtrim(lookup_type)))='CA_PROVINCE' and
4527 upper(ltrim(rtrim(lookup_code)))=upper(ltrim(rtrim(v_province)));
4528
4529 v_province_name hr_lookups.meaning%TYPE;
4530 prev_province_name hr_lookups.meaning%TYPE;
4531
4532 cursor cur_hired(desig NUMBER) is
4533 select
4534 count(distinct person_id) count,
4535 meaning meaning,
4536 employment_category employment_category,
4537 sex sex,
4538 province province
4539 from
4540 (
4541 select
4542 paf.person_id person_id,
4546 hl1.region_1 province
4543 hl.meaning meaning,
4544 substr(paf.employment_category,1,2) employment_category,
4545 ppf.sex sex,
4547 from
4548 hr_lookups hl,
4549 per_jobs pj,
4550 per_assignments_f paf,
4551 per_people_f ppf,
4552 per_person_types ppt,
4553 hr_locations hl1,
4554 per_ca_ee_report_lines pert,
4555 hr_lookups hl2,
4556 hr_soft_coding_keyflex hsck
4557 where
4558 upper(ltrim(rtrim(hl.lookup_type)))='EEOG' and
4559 upper(ltrim(rtrim(hl.lookup_code)))=
4560 upper(ltrim(ltrim(pj.job_information1))) and
4561 upper(ltrim(rtrim(pj.job_information_category))) = 'CA' and
4562 pj.job_id=paf.job_id and
4563 paf.primary_flag = 'Y' and
4564 --decode(paf.employment_category,'PT',p_date_tmp_emp,l_year_end) between
4565 -- paf.effective_start_date and
4566 -- paf.effective_end_date and
4567 --paf.effective_start_date < l_year_end and
4568 --paf.effective_end_date > l_year_start and
4569 ppf.start_date between
4570 paf.effective_start_date and
4571 paf.effective_end_date and
4572 paf.employment_category is not null and
4573 substr(paf.employment_category,1,2) in ('FR','PR','PT') and
4574 paf.person_id=ppf.person_id and
4575 --decode(paf.employment_category,'PT',p_date_tmp_emp,l_year_end) between
4576 -- ppf.effective_start_date and
4577 -- ppf.effective_end_date and
4578 ppf.effective_start_date < l_year_end and
4579 ppf.effective_end_date > l_year_start and
4580 ppf.start_date between l_year_start and
4581 l_year_end and
4582 ppf.person_type_id=ppt.person_type_id and
4583 upper(ltrim(rtrim(ppt.system_person_type)))='EMP' and
4584 ppf.business_group_id=p_business_group_id and
4585 paf.location_id=hl1.location_id and
4586 hl1.region_1=hl2.lookup_code and
4587 hl2.lookup_type='CA_PROVINCE' and
4588 pert.request_id=p_request_id and
4589 hl2.meaning=pert.segment2 and
4590 --pert.segment4 = 'Y' and
4591 pert.context='FORM14' and
4592 pert.segment1='PROVINCE' and
4593 decode(desig,1,ppf.per_information5,
4594 2,ppf.per_information6,
4595 3,ppf.per_information7)='Y' and
4596 (
4597 (
4598 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
4599 hsck.segment6 is not null and
4600 hsck.segment6 = v_naic_code
4601 )
4602 OR
4603 (
4604 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
4605 hsck.segment6 is null and
4606 hsck.segment1 in (select segment3
4607 from per_ca_ee_report_lines
4608 where request_id = p_request_id and
4609 context = 'FORM13' and
4610 segment1 = 'NAIC' and
4611 segment2 = v_naic_code)
4612 )
4613 ) and
4614 exists
4615 (
4616 select 'X'
4617 from per_pay_proposals_v2 pppv
4618 where
4619 pppv.assignment_id = paf.assignment_id and
4620 pppv.approved = 'Y' and
4621 pppv.change_date <= l_year_end
4622 ) -- End of Exists
4623 union all
4624 select
4625 paf.person_id person_id,
4626 hl.meaning meaning,
4627 'FR' employment_category,
4628 ppf.sex sex,
4629 hl1.region_1 province
4630 from
4631 hr_lookups hl,
4632 per_jobs pj,
4633 per_assignments_f paf,
4634 per_people_f ppf,
4635 per_person_types ppt,
4636 hr_locations hl1,
4637 per_ca_ee_report_lines pert,
4638 hr_lookups hl2,
4639 hr_soft_coding_keyflex hsck
4640 where
4641 upper(ltrim(rtrim(hl.lookup_type)))='EEOG' and
4642 upper(ltrim(rtrim(hl.lookup_code)))
4643 = upper(ltrim(ltrim(pj.job_information1))) and
4644 upper(ltrim(rtrim(pj.job_information_category))) = 'CA' and
4645 pj.job_id=paf.job_id and
4646 paf.primary_flag = 'Y' and
4647 --l_year_end between
4648 -- paf.effective_start_date and
4649 -- paf.effective_end_date and
4650 -- paf.effective_start_date < l_year_end and
4651 -- paf.effective_end_date > l_year_start and
4652 ppf.start_date between
4653 paf.effective_start_date and
4654 paf.effective_end_date and
4655 (paf.employment_category is null OR
4656 substr(paf.employment_category,1,2) not in ('FR','PR','PT')) and
4657 paf.person_id=ppf.person_id and
4658 --l_year_end between
4659 -- ppf.effective_start_date and
4660 -- ppf.effective_end_date and
4661 ppf.effective_start_date < l_year_end and
4662 ppf.effective_end_date > l_year_start and
4663 ppf.start_date between l_year_start and
4664 l_year_end and
4665 ppf.person_type_id=ppt.person_type_id and
4666 upper(ltrim(rtrim(ppt.system_person_type)))='EMP' and
4667 ppf.business_group_id=p_business_group_id and
4668 paf.location_id=hl1.location_id and
4669 hl1.region_1=hl2.lookup_code and
4670 hl2.lookup_type='CA_PROVINCE' and
4671 pert.request_id=p_request_id and
4672 hl2.meaning=pert.segment2 and
4673 --pert.segment4 = 'Y' and
4677 2,ppf.per_information6,
4674 pert.context='FORM14' and
4675 pert.segment1='PROVINCE' and
4676 decode(desig,1,ppf.per_information5,
4678 3,ppf.per_information7)='Y' and
4679 (
4680 (
4681 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
4682 hsck.segment6 is not null and
4683 hsck.segment6 = v_naic_code
4684 )
4685 OR
4686 (
4687 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
4688 hsck.segment6 is null and
4689 hsck.segment1 in (select segment3
4690 from per_ca_ee_report_lines
4691 where request_id = p_request_id and
4692 context = 'FORM13' and
4693 segment1 = 'NAIC' and
4694 segment2 = v_naic_code)
4695 )
4696 ) and
4697 exists
4698 (
4699 select 'X'
4700 from per_pay_proposals_v2 pppv
4701 where
4702 pppv.assignment_id = paf.assignment_id and
4703 pppv.approved = 'Y' and
4704 pppv.change_date <= l_year_end
4705 ) -- End of Exists
4706 )
4707 group by province,meaning,employment_category,sex
4708 order by province,meaning,employment_category,sex;
4709
4710 cursor cur_eeog is
4711 select
4712 meaning
4713 from
4714 hr_lookups
4715 where
4716 lookup_type='EEOG';
4717
4718 cursor cur_notfound(p_emp_cat number) is
4719 select
4720 segment2,
4721 v_meaning,
4722 decode(p_emp_cat,1,'FR',2,'PR',3,'PT') emp_category
4723 from
4724 per_ca_ee_report_lines where
4725 request_id=p_request_id and
4726 context='FORM14' and
4727 segment1='PROVINCE' and
4728 segment3 <> '0'
4729 minus
4730 select
4731 segment2,
4732 segment3,
4733 segment4
4734 from
4735 per_ca_ee_report_lines
4736 where
4737 request_id=p_request_id and
4738 context='FORM4' and
4739 segment1='PROVINCE'and
4740 segment21 = v_naic_code;
4741
4742 cursor cur_count_national is
4743 select
4744 segment3,
4745 segment4,
4746 sum(to_number(segment5)) segment5,
4747 sum(to_number(segment6)) segment6,
4748 sum(to_number(segment7)) segment7,
4749 sum(to_number(segment8)) segment8,
4750 sum(to_number(segment9)) segment9,
4751 sum(to_number(segment10)) segment10,
4752 sum(to_number(segment11)) segment11,
4753 sum(to_number(segment12)) segment12,
4754 sum(to_number(segment13)) segment13,
4755 sum(to_number(segment14)) segment14,
4756 sum(to_number(segment15)) segment15,
4757 sum(to_number(segment16)) segment16
4758 from
4759 per_ca_ee_report_lines
4760 where
4761 request_id = p_request_id and
4762 context = 'FORM4' and
4763 segment1 = 'PROVINCE' and
4764 segment21 = v_naic_code
4765 group by segment3,segment4;
4766
4767 begin
4768
4769 hr_utility.trace('Form4 starts Here !!!!!!');
4770
4771 for naic in cur_naic loop
4772
4773 v_naic_code := naic.naic_code;
4774
4775 hr_utility.trace('Form4: v_naic = ' || v_naic_code );
4776
4777 for j in cur_hired_total
4778 loop
4779
4780 v_count := j.count_total;
4781 v_meaning := j.meaning;
4782 v_employment_category := j.employment_category;
4783 v_sex := j.sex;
4784 v_province := j.province;
4785
4786 hr_utility.trace('Form4: v_meaning = ' || v_meaning );
4787
4788 open cur_meaning;
4789 fetch cur_meaning into v_province_name;
4790 close cur_meaning;
4791
4792 if ((ltrim(rtrim(v_province_name))<>ltrim(rtrim(prev_province_name))) or
4793 (ltrim(rtrim(prev_meaning)) <> ltrim(rtrim(v_meaning))) or
4794 (ltrim(rtrim(prev_naic_code)) <> ltrim(rtrim(v_naic_code))) or
4795 (ltrim(rtrim(prev_employment_category)) <> ltrim(rtrim(v_employment_category)))) then
4796
4797 per_ca_ee_extract_pkg.k := per_ca_ee_extract_pkg.k + 1;
4798
4799 insert into per_ca_ee_report_lines
4800 (request_id,
4801 line_number,
4802 context,
4803 segment1,
4804 segment2,
4805 segment3,
4806 segment4,
4807 segment5,
4808 segment6,
4809 segment7,
4810 segment8,
4811 segment9,
4812 segment10,
4813 segment11,
4814 segment12,
4815 segment13,
4816 segment14,
4817 segment15,
4818 segment16,
4819 segment21) values
4820 ( p_request_id,
4821 per_ca_ee_extract_pkg.k,
4822 'FORM4',
4823 'PROVINCE',
4824 v_province_name,
4825 v_meaning,
4826 v_employment_category,
4827 nvl(v_count,0),
4828 decode(v_sex,'F',v_count,0),
4829 decode(v_sex,'M',v_count,0),
4830 '0',
4831 '0',
4832 '0',
4836 '0',
4833 '0',
4834 '0',
4835 '0',
4837 '0',
4838 '0',
4839 v_naic_code);
4840
4841 else
4842
4843 if prev_province_name = v_province_name and
4844 prev_meaning = v_meaning and
4845 prev_naic_code = v_naic_code and
4846 prev_employment_category = v_employment_category and
4847 prev_sex <> v_sex then
4848
4849 if v_sex = 'M' then
4850
4851 update per_ca_ee_report_lines set
4852 segment7=nvl(v_count,0),
4853 segment5=segment5 + nvl(v_count,0)
4854 where request_id=p_request_id and
4855 line_number=per_ca_ee_extract_pkg.k and
4856 context='FORM4' and
4857 segment1='PROVINCE' and
4858 segment2=v_province_name and
4859 segment3=v_meaning and
4860 segment4=v_employment_category and
4861 segment21 = v_naic_code;
4862
4863 elsif v_sex = 'F' then
4864
4865 update per_ca_ee_report_lines set
4866 segment6=nvl(v_count,0),
4867 segment5=segment5 + nvl(v_count,0)
4868 where request_id=p_request_id and
4869 line_number=per_ca_ee_extract_pkg.k and
4870 context='FORM4' and
4871 segment1='PROVINCE' and
4872 segment2=v_province_name and
4873 segment3=v_meaning and
4874 segment4=v_employment_category and
4875 segment21 = v_naic_code;
4876
4877 end if;
4878
4879 end if;
4880 end if;
4881
4882 prev_meaning := v_meaning;
4883 prev_employment_category := v_employment_category;
4884 prev_sex := v_sex;
4885 prev_province_name := v_province_name;
4886 prev_naic_code := v_naic_code;
4887
4888 end loop; -- End loop cur_hired_total
4889
4890 for i in 1..3 loop
4891
4892 for j in cur_hired(i)
4893 loop
4894
4895 v_sex := j.sex;
4896 v_employment_category := j.employment_category;
4897 v_meaning := j.meaning;
4898 v_count := j.count;
4899 v_province := j.province;
4900
4901 open cur_meaning;
4902 fetch cur_meaning into v_province_name;
4903 close cur_meaning;
4904
4905 if i = 1 then
4906 if v_sex = 'M' then
4907 update per_ca_ee_report_lines set
4908 segment8 = nvl(segment8,0) + nvl(v_count,0),
4909 segment10 = nvl(v_count,0)
4910 where
4911 request_id = p_request_id and
4912 context='FORM4' and
4913 segment1 = 'PROVINCE' and
4914 segment2 = v_province_name and
4915 segment3 = v_meaning and
4916 segment4 = v_employment_category;
4917 elsif v_sex = 'F' then
4918 update per_ca_ee_report_lines set
4919 segment8 = nvl(segment8,0) + nvl(v_count,0),
4920 segment9 = nvl(v_count,0)
4921 where
4922 request_id = p_request_id and
4923 context='FORM4' and
4924 segment1 = 'PROVINCE' and
4925 segment2 = v_province_name and
4926 segment3 = v_meaning and
4927 segment4 = v_employment_category;
4928 end if;
4929 elsif i = 2 then
4930 if v_sex = 'M' then
4931 update per_ca_ee_report_lines set
4932 segment11 = nvl(segment11,0) + nvl(v_count,0),
4933 segment13 = nvl(v_count,0)
4934 where
4935 request_id = p_request_id and
4936 context='FORM4' and
4937 segment1 = 'PROVINCE' and
4938 segment2 = v_province_name and
4939 segment3 = v_meaning and
4940 segment4 = v_employment_category;
4941 elsif v_sex = 'F' then
4942 update per_ca_ee_report_lines set
4943 segment11 = nvl(segment11,0) + nvl(v_count,0),
4944 segment12 = nvl(v_count,0)
4945 where
4946 request_id = p_request_id and
4947 context='FORM4' and
4948 segment1 = 'PROVINCE' and
4949 segment2 = v_province_name and
4950 segment3 = v_meaning and
4951 segment4 = v_employment_category;
4952 end if;
4956 segment14 = nvl(segment14,0) + nvl(v_count,0),
4953 elsif i = 3 then
4954 if v_sex = 'M' then
4955 update per_ca_ee_report_lines set
4957 segment16 = nvl(v_count,0)
4958 where
4959 request_id = p_request_id and
4960 context='FORM4' and
4961 segment1 = 'PROVINCE' and
4962 segment2 = v_province_name and
4963 segment3 = v_meaning and
4964 segment4 = v_employment_category;
4965 elsif v_sex = 'F' then
4966 update per_ca_ee_report_lines set
4967 segment14 = nvl(segment14,0) + nvl(v_count,0),
4968 segment15 = nvl(v_count,0)
4969 where
4970 request_id = p_request_id and
4971 context='FORM4' and
4972 segment1 = 'PROVINCE' and
4973 segment2 = v_province_name and
4974 segment3 = v_meaning and
4975 segment4 = v_employment_category;
4976 end if;
4977 end if;
4978 end loop; -- End loop cur_hired
4979
4980 end loop; -- End loop for designated group
4981
4982 for i in cur_eeog loop
4983
4984 v_meaning := i.meaning;
4985
4986 hr_utility.trace('Form4: cur_eeog: v_eeog' || v_meaning);
4987
4988 for emp_cat in 1..3 loop
4989
4990 for x in cur_notfound(emp_cat) loop
4991
4992 per_ca_ee_extract_pkg.k := per_ca_ee_extract_pkg.k + 1;
4993
4994 insert into per_ca_ee_report_lines
4995 (request_id,
4996 line_number,
4997 context,
4998 segment1,
4999 segment2,
5000 segment3,
5001 segment4,
5002 segment5,
5003 segment6,
5004 segment7,
5005 segment8,
5006 segment9,
5007 segment10,
5008 segment11,
5009 segment12,
5010 segment13,
5011 segment14,
5012 segment15,
5013 segment16,
5014 segment21) values
5015 ( p_request_id,
5016 per_ca_ee_extract_pkg.k,
5017 'FORM4',
5018 'PROVINCE',
5019 x.segment2,
5020 v_meaning,
5021 x.emp_category,
5022 0,
5023 0,
5024 0,
5025 0,
5026 0,
5027 0,
5028 0,
5029 0,
5030 0,
5031 0,
5032 0,
5033 0,
5034 v_naic_code);
5035
5036 end loop;
5037
5038 end loop;
5039
5040 end loop;
5041
5042
5043 hr_utility.trace('Form4: End of loop cur_naic');
5044
5045 for count_national in cur_count_national loop
5046
5047 hr_utility.trace('Form4: cur_count_national. ');
5048
5049 insert into per_ca_ee_report_lines
5050 (request_id,
5051 line_number,
5052 context,
5053 segment1,
5054 segment2,
5055 segment3,
5056 segment4,
5057 segment5,
5058 segment6,
5059 segment7,
5060 segment8,
5061 segment9,
5062 segment10,
5063 segment11,
5064 segment12,
5065 segment13,
5066 segment14,
5067 segment15,
5068 segment21) values
5069 ( p_request_id,
5070 per_ca_ee_extract_pkg.k,
5071 'FORM4',
5072 'NATIONAL',
5073 count_national.segment3,
5074 count_national.segment4,
5075 count_national.segment5,
5076 count_national.segment6,
5077 count_national.segment7,
5078 count_national.segment8,
5079 count_national.segment9,
5080 count_national.segment10,
5081 count_national.segment11,
5082 count_national.segment12,
5083 count_national.segment13,
5084 count_national.segment14,
5085 count_national.segment15,
5086 count_national.segment16,
5087 v_naic_code);
5088
5089 end loop; -- End loop cur_count_total
5090
5091 prev_naic_code := v_naic_code;
5092
5093 end loop; -- End of loop cur_naic
5094
5095
5096 return 1;
5097
5098 end;
5099
5100 end form4;
5101 /*
5102 function form5(p_business_group_id in number,
5103 p_request_id in number,
5104 p_year in varchar2,
5105 p_date_tmp_emp in date) return number is
5106
5107 l_year_start date;
5111
5108 l_year_end date;
5109
5110 begin
5112 l_year_start := trunc(to_date(p_year,'YYYY'),'Y');
5113 l_year_end := add_months(trunc(to_date(p_year,'YYYY'),'Y'), 12) -1;
5114
5115 declare
5116
5117 cursor cur_naic is
5118 select
5119 pert.segment4 naic_code
5120 from
5121 per_ca_ee_report_lines pert
5122 where
5123 pert.request_id = p_request_id and
5124 pert.context = 'FORM12';
5125
5126 v_naic_code hr_lookups.lookup_code%TYPE;
5127
5128 cursor cur_promoted_total is
5129 select
5130 count(distinct count_total) count_total,
5131 meaning meaning,
5132 sex sex,
5133 employment_category employment_category,
5134 province province
5135 from
5136 (
5137 select
5138 paf.person_id count_total,
5139 hl.meaning meaning,
5140 ppf.sex sex,
5141 substr(paf.employment_category,1,2) employment_category,
5142 hl1.region_1 province
5143 from
5144 hr_lookups hl,
5145 per_jobs pj,
5146 per_assignments_f paf,
5147 per_people_f ppf,
5148 per_person_types ppt,
5149 hr_locations hl1,
5150 per_ca_ee_report_lines pert,
5151 hr_lookups hl2,
5152 hr_soft_coding_keyflex hsck
5153 where
5154 hl.lookup_type='EEOG' and
5155 upper(ltrim(rtrim(hl.lookup_code)))
5156 =upper(ltrim(rtrim(pj.job_information1))) and
5157 upper(ltrim(rtrim(pj.job_information_category))) = 'CA' and
5158 pj.job_id=paf.job_id and
5159 paf.primary_flag = 'Y' and
5160 --decode(paf.employment_category,'PT',p_date_tmp_emp,l_year_end) between
5161 -- paf.effective_start_date and
5162 -- paf.effective_end_date and
5163 ppf.start_date between
5164 paf.effective_start_date and
5165 paf.effective_end_date and
5166 paf.employment_category is not null and
5167 substr(paf.employment_category,1,2) in ('FR','PR','PT') and
5168 paf.person_id=ppf.person_id and
5169 --decode(paf.employment_category,'PT',p_date_tmp_emp,l_year_end) between
5170 -- ppf.effective_start_date and
5171 -- ppf.effective_end_date and
5172 ppf.effective_start_date < l_year_end and
5173 ppf.effective_end_date > l_year_start and
5174 ppf.person_type_id=ppt.person_type_id and
5175 upper(ltrim(rtrim(ppt.system_person_type)))='EMP' and
5176 ppf.business_group_id=p_business_group_id and
5177 paf.location_id=hl1.location_id and
5178 hl1.region_1=hl2.lookup_code and
5179 hl2.lookup_type='CA_PROVINCE' and
5180 pert.request_id=p_request_id and
5181 hl2.meaning=pert.segment2 and
5182 --pert.segment4 = 'Y' and
5183 pert.context='FORM14' and
5184 pert.segment1='PROVINCE' and
5185 (
5186 (
5187 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
5188 hsck.segment6 is not null and
5189 hsck.segment6 = v_naic_code
5190 )
5191 OR
5192 (
5193 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
5194 hsck.segment6 is null and
5195 hsck.segment1 in (select segment3
5196 from per_ca_ee_report_lines
5197 where request_id = p_request_id and
5198 context = 'FORM13' and
5199 segment1 = 'NAIC' and
5200 segment2 = v_naic_code)
5201 )
5202 ) and
5203 exists
5204 (
5205 select 'X'
5206 from per_pay_proposals_v2 pppv
5207 where
5208 pppv.assignment_id = paf.assignment_id and
5209 pppv.approved = 'Y' and
5210 pppv.change_date between l_year_start and
5211 l_year_end and
5212 pppv.proposal_reason =
5213 (
5214 select lookup_code
5215 from hr_lookups
5216 where lookup_type = 'PROPOSAL_REASON' and
5217 upper(meaning) = 'PROMOTION'
5218 )
5219 )
5220 union all
5221 select
5222 paf.person_id count_total,
5223 hl.meaning meaning,
5224 ppf.sex sex,
5225 'FR' employment_category,
5226 hl1.region_1 province
5227 from
5228 hr_lookups hl,
5229 per_jobs pj,
5230 per_assignments_f paf,
5231 per_people_f ppf,
5232 per_person_types ppt,
5233 hr_locations hl1,
5234 per_ca_ee_report_lines pert,
5235 hr_lookups hl2,
5236 hr_soft_coding_keyflex hsck
5237 where
5238 hl.lookup_type='EEOG' and
5239 upper(ltrim(rtrim(hl.lookup_code)))
5240 =upper(ltrim(rtrim(pj.job_information1))) and
5241 upper(ltrim(rtrim(pj.job_information_category))) = 'CA' and
5242 pj.job_id=paf.job_id and
5243 paf.primary_flag = 'Y' and
5244 --l_year_end between
5245 -- ppf.effective_start_date and
5246 -- ppf.effective_end_date and
5247 ppf.start_date between
5248 paf.effective_start_date and
5249 paf.effective_end_date and
5253 ppf.effective_start_date < l_year_end and
5250 (paf.employment_category is null OR
5251 substr(paf.employment_category,1,2) not in ('FR','PR','PT')) and
5252 paf.person_id=ppf.person_id and
5254 ppf.effective_end_date > l_year_start and
5255 --l_year_end between
5256 -- ppf.effective_start_date and
5257 -- ppf.effective_end_date and
5258 ppf.person_type_id=ppt.person_type_id and
5259 upper(ltrim(rtrim(ppt.system_person_type)))='EMP' and
5260 ppf.business_group_id=p_business_group_id and
5261 paf.location_id=hl1.location_id and
5262 hl1.region_1=hl2.lookup_code and
5263 hl2.lookup_type='CA_PROVINCE' and
5264 pert.request_id=p_request_id and
5265 hl2.meaning=pert.segment2 and
5266 --pert.segment4 = 'Y' and
5267 pert.context='FORM14' and
5268 pert.segment1='PROVINCE' and
5269 (
5270 (
5271 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
5272 hsck.segment6 is not null and
5273 hsck.segment6 = v_naic_code
5274 )
5275 OR
5276 (
5277 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
5278 hsck.segment6 is null and
5279 hsck.segment1 in (select segment3
5280 from per_ca_ee_report_lines
5281 where request_id = p_request_id and
5282 context = 'FORM13' and
5283 segment1 = 'NAIC' and
5284 segment2 = v_naic_code)
5285 )
5286 ) and
5287 exists
5288 (
5289 select 'X'
5290 from per_pay_proposals_v2 pppv
5291 where
5292 pppv.assignment_id = paf.assignment_id and
5293 pppv.approved = 'Y' and
5294 pppv.change_date between l_year_start and
5295 l_year_end and
5296 pppv.proposal_reason =
5297 (
5298 select lookup_code
5299 from hr_lookups
5300 where lookup_type = 'PROPOSAL_REASON' and
5301 upper(meaning) = 'PROMOTION'
5302 )
5303 )
5304 )
5305 group by province,meaning,employment_category,sex
5306 order by province,meaning,employment_category,sex;
5307
5308 v_count number(10);
5309 v_meaning hr_lookups.meaning%TYPE;
5310 v_employment_category per_assignments_f.employment_category%TYPE;
5311 v_sex per_people_f.sex%TYPE;
5312 v_province hr_locations.region_1%TYPE;
5313 prev_meaning hr_lookups.meaning%TYPE := 'test';
5314 prev_employment_category per_assignments_f.employment_category%TYPE := 'test';
5315 prev_sex per_people_f.sex%TYPE := 'test';
5316 prev_naic_code hr_lookups.lookup_code%TYPE;
5317
5318 cursor cur_meaning is select
5319 meaning
5320 from
5321 hr_lookups
5322 where
5323 upper(ltrim(rtrim(lookup_type)))='CA_PROVINCE' and
5324 upper(ltrim(rtrim(lookup_code)))=upper(ltrim(rtrim(v_province)));
5325
5326 v_province_name hr_lookups.meaning%TYPE;
5327 prev_province_name hr_lookups.meaning%TYPE;
5328
5329 cursor cur_promoted(desig NUMBER) is
5330 select
5331 count(distinct person_id) count,
5332 meaning meaning,
5333 employment_category employment_category,
5334 sex sex,
5335 province province
5336 from
5337 (
5338 select
5339 paf.person_id person_id,
5340 hl.meaning meaning,
5341 substr(paf.employment_category,1,2) employment_category,
5342 ppf.sex sex,
5343 hl1.region_1 province
5344 from
5345 hr_lookups hl,
5346 per_jobs pj,
5347 per_assignments_f paf,
5348 per_people_f ppf,
5349 per_person_types ppt,
5350 hr_locations hl1,
5351 per_ca_ee_report_lines pert,
5352 hr_lookups hl2,
5353 hr_soft_coding_keyflex hsck
5354 where
5355 upper(ltrim(rtrim(hl.lookup_type)))='EEOG' and
5356 upper(ltrim(rtrim(hl.lookup_code)))=upper(ltrim(ltrim(pj.job_information1))) and
5357 upper(ltrim(rtrim(pj.job_information_category))) = 'CA' and
5358 pj.job_id=paf.job_id and
5359 paf.primary_flag = 'Y' and
5360 --decode(paf.employment_category,'PT',p_date_tmp_emp,l_year_end) between
5361 -- ppf.effective_start_date and
5362 -- ppf.effective_end_date and
5363 ppf.start_date between
5364 paf.effective_start_date and
5365 paf.effective_end_date and
5366 paf.employment_category is not null and
5367 substr(paf.employment_category,1,2) in ('FR','PR','PT')and
5368 paf.person_id=ppf.person_id and
5369 --decode(paf.employment_category,'PT',p_date_tmp_emp,l_year_end) between
5370 -- ppf.effective_start_date and
5371 -- ppf.effective_end_date and
5372 ppf.effective_start_date < l_year_end and
5373 ppf.effective_end_date > l_year_start and
5374 ppf.person_type_id=ppt.person_type_id and
5375 upper(ltrim(rtrim(ppt.system_person_type)))='EMP' and
5376 ppf.business_group_id=p_business_group_id and
5377 paf.location_id=hl1.location_id and
5378 hl1.region_1=hl2.lookup_code and
5379 hl2.lookup_type='CA_PROVINCE' and
5380 pert.request_id=p_request_id and
5381 hl2.meaning=pert.segment2 and
5385 decode(desig,1,per_information5,
5382 --pert.segment4 = 'Y' and
5383 pert.context='FORM14' and
5384 pert.segment1='PROVINCE' and
5386 2,per_information6,
5387 3,per_information7)='Y' and
5388 (
5389 (
5390 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
5391 hsck.segment6 is not null and
5392 hsck.segment6 = v_naic_code
5393 )
5394 OR
5395 (
5396 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
5397 hsck.segment6 is null and
5398 hsck.segment1 in (select segment3
5399 from per_ca_ee_report_lines
5400 where request_id = p_request_id and
5401 context = 'FORM13' and
5402 segment1 = 'NAIC' and
5403 segment2 = v_naic_code)
5404 )
5405 ) and
5406 exists
5407 (
5408 select 'X'
5409 from per_pay_proposals_v2 pppv
5410 where
5411 pppv.assignment_id = paf.assignment_id and
5412 pppv.change_date between l_year_start and
5413 l_year_end and
5414 pppv.approved = 'Y' and
5415 pppv.proposal_reason =
5416 (
5417 select lookup_code
5418 from hr_lookups
5419 where lookup_type = 'PROPOSAL_REASON' and
5420 upper(meaning) = 'PROMOTION'
5421 )
5422 )
5423 union all
5424 select
5425 paf.person_id person_id,
5426 hl.meaning meaning,
5427 'FR' employment_category,
5428 ppf.sex sex,
5429 hl1.region_1 province
5430 from
5431 hr_lookups hl,
5432 per_jobs pj,
5433 per_assignments_f paf,
5434 per_people_f ppf,
5435 per_person_types ppt,
5436 hr_locations hl1,
5437 per_ca_ee_report_lines pert,
5438 hr_lookups hl2,
5439 hr_soft_coding_keyflex hsck
5440 where
5441 upper(ltrim(rtrim(hl.lookup_type)))='EEOG' and
5442 upper(ltrim(rtrim(hl.lookup_code)))=upper(ltrim(ltrim(pj.job_information1))) and
5443 upper(ltrim(rtrim(pj.job_information_category))) = 'CA' and
5444 pj.job_id=paf.job_id and
5445 paf.primary_flag = 'Y' and
5446 --l_year_end between
5447 -- paf.effective_start_date and
5448 -- paf.effective_end_date and
5449 ppf.effective_start_date between
5450 paf.effective_start_date and
5451 paf.effective_end_date and
5452 (paf.employment_category is null OR
5453 substr(paf.employment_category,1,2) not in ('FR','PR','PT'))and
5454 paf.person_id=ppf.person_id and
5455 --l_year_end between
5456 -- ppf.effective_start_date and
5457 -- ppf.effective_end_date and
5458 ppf.effective_start_date < l_year_end and
5459 ppf.effective_end_date > l_year_start and
5460 ppf.person_type_id=ppt.person_type_id and
5461 upper(ltrim(rtrim(ppt.system_person_type)))='EMP' and
5462 ppf.business_group_id=p_business_group_id and
5463 paf.location_id=hl1.location_id and
5464 hl1.region_1=hl2.lookup_code and
5465 hl2.lookup_type='CA_PROVINCE' and
5466 pert.request_id=p_request_id and
5467 hl2.meaning=pert.segment2 and
5468 --pert.segment4 = 'Y' and
5469 pert.context='FORM14' and
5470 pert.segment1='PROVINCE' and
5471 decode(desig,1,per_information5,
5472 2,per_information6,
5473 3,per_information7)='Y' and
5474 (
5475 (
5476 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
5477 hsck.segment6 is not null and
5478 hsck.segment6 = v_naic_code
5479 )
5480 OR
5481 (
5482 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
5483 hsck.segment6 is null and
5484 hsck.segment1 in (select segment3
5485 from per_ca_ee_report_lines
5486 where request_id = p_request_id and
5487 context = 'FORM13' and
5488 segment1 = 'NAIC' and
5489 segment2 = v_naic_code)
5490 )
5491 ) and
5492 exists
5493 (
5494 select 'X'
5495 from per_pay_proposals_v2 pppv
5496 where
5497 pppv.assignment_id = paf.assignment_id and
5498 pppv.approved = 'Y'and
5499 pppv.change_date between l_year_start and
5500 l_year_end and
5501 pppv.proposal_reason =
5502 (
5503 select lookup_code
5504 from hr_lookups
5505 where lookup_type = 'PROPOSAL_REASON' and
5506 upper(meaning) = 'PROMOTION'
5507 )
5508 )
5509 )
5510 group by province,meaning,employment_category,sex
5511 order by province,meaning,employment_category,sex;
5512
5513 cursor cur_eeog is
5514 select
5515 meaning
5516 from
5517 hr_lookups
5518 where
5519 lookup_type='EEOG';
5520
5521 cursor cur_notfound(p_emp_cat number) is
5522 select
5523 segment2,
5524 v_meaning,
5525 decode(p_emp_cat,1,'FR',2,'PR',3,'PT') emp_category
5526 from
5530 segment1='PROVINCE' and
5527 per_ca_ee_report_lines where
5528 request_id=p_request_id and
5529 context='FORM14' and
5531 segment3 <> '0'
5532 minus
5533 select
5534 segment2,
5535 segment3,
5536 segment4
5537 from
5538 per_ca_ee_report_lines
5539 where
5540 request_id=p_request_id and
5541 context='FORM5' and
5542 segment1='PROVINCE'and
5543 segment21 = v_naic_code;
5544
5545 cursor cur_count_national is
5546 select
5547 segment3,
5548 segment4,
5549 sum(to_number(segment5)) segment5,
5550 sum(to_number(segment6)) segment6,
5551 sum(to_number(segment7)) segment7,
5552 sum(to_number(segment8)) segment8,
5553 sum(to_number(segment9)) segment9,
5554 sum(to_number(segment10)) segment10,
5555 sum(to_number(segment11)) segment11,
5556 sum(to_number(segment12)) segment12,
5557 sum(to_number(segment13)) segment13,
5558 sum(to_number(segment14)) segment14,
5559 sum(to_number(segment15)) segment15,
5560 sum(to_number(segment16)) segment16
5561 from
5562 per_ca_ee_report_lines
5563 where
5564 request_id = p_request_id and
5565 context = 'FORM5' and
5566 segment1 = 'PROVINCE' and
5567 segment21 = v_naic_code
5568 group by segment3,segment4;
5569
5570 cursor cur_count_promotions is
5571 select
5572 count(count_total) count_total,
5573 sex sex,
5574 employment_category employment_category,
5575 province province
5576 from
5577 (
5578 select
5579 paf.person_id count_total,
5580 ppf.sex sex,
5581 substr(paf.employment_category,1,2) employment_category,
5582 hl1.region_1 province
5583 from
5584 hr_lookups hl,
5585 per_jobs pj,
5586 per_assignments_f paf,
5587 per_people_f ppf,
5588 per_person_types ppt,
5589 hr_locations hl1,
5590 per_ca_ee_report_lines pert,
5591 hr_lookups hl2,
5592 hr_soft_coding_keyflex hsck,
5593 per_pay_proposals_v2 pppv
5594 where
5595 hl.lookup_type='EEOG' and
5596 upper(ltrim(rtrim(hl.lookup_code)))
5597 =upper(ltrim(rtrim(pj.job_information1))) and
5598 upper(ltrim(rtrim(pj.job_information_category))) = 'CA' and
5599 pj.job_id=paf.job_id and
5600 paf.primary_flag = 'Y' and
5601 --decode(paf.employment_category,'PT',p_date_tmp_emp,l_year_end) between
5602 -- paf.effective_start_date and
5603 -- paf.effective_end_date and
5604 ppf.start_date between
5605 paf.effective_start_date and
5606 paf.effective_end_date and
5607 paf.employment_category is not null and
5608 substr(paf.employment_category,1,2) in ('FR','PR','PT') and
5609 paf.person_id=ppf.person_id and
5610 --decode(paf.employment_category,'PT',p_date_tmp_emp,l_year_end) between
5611 -- ppf.effective_start_date and
5612 -- ppf.effective_end_date and
5613 ppf.effective_start_date < l_year_end and
5614 ppf.effective_end_date > l_year_start and
5615 ppf.person_type_id=ppt.person_type_id and
5616 upper(ltrim(rtrim(ppt.system_person_type)))='EMP' and
5617 ppf.business_group_id=p_business_group_id and
5618 paf.location_id=hl1.location_id and
5619 hl1.region_1=hl2.lookup_code and
5620 hl2.lookup_type='CA_PROVINCE' and
5621 pert.request_id=p_request_id and
5622 hl2.meaning=pert.segment2 and
5623 --pert.segment4 = 'Y' and
5624 pert.context='FORM14' and
5625 pert.segment1='PROVINCE' and
5626 (
5627 (
5628 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
5629 hsck.segment6 is not null and
5630 hsck.segment6 = v_naic_code
5631 )
5632 OR
5633 (
5634 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
5635 hsck.segment6 is null and
5636 hsck.segment1 in (select segment3
5637 from per_ca_ee_report_lines
5638 where request_id = p_request_id and
5639 context = 'FORM13' and
5640 segment1 = 'NAIC' and
5641 segment2 = v_naic_code)
5642 )
5643 ) and
5644 pppv.assignment_id = paf.assignment_id and
5645 pppv.approved = 'Y' and
5646 pppv.change_date between l_year_start and
5647 l_year_end and
5648 pppv.proposal_reason =
5649 (
5650 select lookup_code
5651 from hr_lookups
5652 where lookup_type = 'PROPOSAL_REASON' and
5653 upper(meaning) = 'PROMOTION'
5654 )
5655 union all
5656 select
5657 paf.person_id count_total,
5658 ppf.sex sex,
5659 'FR' employment_category,
5660 hl1.region_1 province
5661 from
5665 per_people_f ppf,
5662 hr_lookups hl,
5663 per_jobs pj,
5664 per_assignments_f paf,
5666 per_person_types ppt,
5667 hr_locations hl1,
5668 per_ca_ee_report_lines pert,
5669 hr_lookups hl2,
5670 hr_soft_coding_keyflex hsck,
5671 per_pay_proposals_v2 pppv
5672 where
5673 hl.lookup_type='EEOG' and
5674 upper(ltrim(rtrim(hl.lookup_code)))
5675 =upper(ltrim(rtrim(pj.job_information1))) and
5676 upper(ltrim(rtrim(pj.job_information_category))) = 'CA' and
5677 pj.job_id=paf.job_id and
5678 paf.primary_flag = 'Y' and
5679 --l_year_end between
5680 -- ppf.effective_start_date and
5681 -- ppf.effective_end_date and
5682 ppf.start_date between
5683 paf.effective_start_date and
5684 paf.effective_end_date and
5685 (paf.employment_category is null OR
5686 substr(paf.employment_category,1,2) not in ('FR','PR','PT')) and
5687 paf.person_id=ppf.person_id and
5688 ppf.effective_start_date < l_year_end and
5689 ppf.effective_end_date > l_year_start and
5690 --l_year_end between
5691 -- ppf.effective_start_date and
5692 -- ppf.effective_end_date and
5693 ppf.person_type_id=ppt.person_type_id and
5694 upper(ltrim(rtrim(ppt.system_person_type)))='EMP' and
5695 ppf.business_group_id=p_business_group_id and
5696 paf.location_id=hl1.location_id and
5697 hl1.region_1=hl2.lookup_code and
5698 hl2.lookup_type='CA_PROVINCE' and
5699 pert.request_id=p_request_id and
5700 hl2.meaning=pert.segment2 and
5701 --pert.segment4 = 'Y' and
5702 pert.context='FORM14' and
5703 pert.segment1='PROVINCE' and
5704 (
5705 (
5706 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
5707 hsck.segment6 is not null and
5708 hsck.segment6 = v_naic_code
5709 )
5710 OR
5711 (
5712 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
5713 hsck.segment6 is null and
5714 hsck.segment1 in (select segment3
5715 from per_ca_ee_report_lines
5716 where request_id = p_request_id and
5717 context = 'FORM13' and
5718 segment1 = 'NAIC' and
5719 segment2 = v_naic_code)
5720 )
5721 ) and
5722 pppv.assignment_id = paf.assignment_id and
5723 pppv.approved = 'Y' and
5724 pppv.change_date between l_year_start and
5725 l_year_end and
5726 pppv.proposal_reason =
5727 (
5728 select lookup_code
5729 from hr_lookups
5730 where lookup_type = 'PROPOSAL_REASON' and
5731 upper(meaning) = 'PROMOTION'
5732 )
5733 )
5734 group by province,employment_category,sex
5735 order by province,employment_category,sex;
5736
5737
5738 cursor cur_total_promotions is
5739 select
5740 count(count_total) count_total,
5741 sex sex,
5742 employment_category employment_category,
5743 province province
5744 from
5745 (
5746 select
5747 paf.person_id count_total,
5748 ppf.sex sex,
5749 substr(paf.employment_category,1,2) employment_category,
5750 hl1.region_1 province
5751 from
5752 hr_lookups hl,
5753 per_jobs pj,
5754 per_assignments_f paf,
5755 per_people_f ppf,
5756 per_person_types ppt,
5757 hr_locations hl1,
5758 per_ca_ee_report_lines pert,
5759 hr_lookups hl2,
5760 hr_soft_coding_keyflex hsck,
5761 per_pay_proposals_v2 pppv
5762 where
5763 hl.lookup_type='EEOG' and
5764 upper(ltrim(rtrim(hl.lookup_code)))
5765 =upper(ltrim(rtrim(pj.job_information1))) and
5766 upper(ltrim(rtrim(pj.job_information_category))) = 'CA' and
5767 pj.job_id=paf.job_id and
5768 paf.primary_flag = 'Y' and
5769 --decode(paf.employment_category,'PT',p_date_tmp_emp,l_year_end) between
5770 -- paf.effective_start_date and
5771 -- paf.effective_end_date and
5772 ppf.start_date between
5773 paf.effective_start_date and
5774 paf.effective_end_date and
5775 paf.employment_category is not null and
5776 substr(paf.employment_category,1,2) in ('FR','PR','PT') and
5777 paf.person_id=ppf.person_id and
5778 --decode(paf.employment_category,'PT',p_date_tmp_emp,l_year_end) between
5779 -- ppf.effective_start_date and
5780 -- ppf.effective_end_date and
5781 ppf.effective_start_date < l_year_end and
5782 ppf.effective_end_date > l_year_start and
5783 ppf.person_type_id=ppt.person_type_id and
5784 upper(ltrim(rtrim(ppt.system_person_type)))='EMP' and
5785 ppf.business_group_id=p_business_group_id and
5786 paf.location_id=hl1.location_id and
5787 hl1.region_1=hl2.lookup_code and
5788 hl2.lookup_type='CA_PROVINCE' and
5789 pert.request_id=p_request_id and
5793 pert.segment1='PROVINCE' and
5790 hl2.meaning=pert.segment2 and
5791 --pert.segment4 = 'Y' and
5792 pert.context='FORM14' and
5794 (
5795 (
5796 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
5797 hsck.segment6 is not null and
5798 hsck.segment6 = v_naic_code
5799 )
5800 OR
5801 (
5802 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
5803 hsck.segment6 is null and
5804 hsck.segment1 in (select segment3
5805 from per_ca_ee_report_lines
5806 where request_id = p_request_id and
5807 context = 'FORM13' and
5808 segment1 = 'NAIC' and
5809 segment2 = v_naic_code)
5810 )
5811 ) and
5812 pppv.assignment_id = paf.assignment_id and
5813 pppv.approved = 'Y' and
5814 pppv.change_date between l_year_start and
5815 l_year_end and
5816 pppv.proposal_reason =
5817 (
5818 select lookup_code
5819 from hr_lookups
5820 where lookup_type = 'PROPOSAL_REASON' and
5821 upper(meaning) = 'PROMOTION'
5822 )
5823 union all
5824 select
5825 paf.person_id count_total,
5826 ppf.sex sex,
5827 'FR' employment_category,
5828 hl1.region_1 province
5829 from
5830 hr_lookups hl,
5831 per_jobs pj,
5832 per_assignments_f paf,
5833 per_people_f ppf,
5834 per_person_types ppt,
5835 hr_locations hl1,
5836 per_ca_ee_report_lines pert,
5837 hr_lookups hl2,
5838 hr_soft_coding_keyflex hsck,
5839 per_pay_proposals_v2 pppv
5840 where
5841 hl.lookup_type='EEOG' and
5842 upper(ltrim(rtrim(hl.lookup_code)))
5843 =upper(ltrim(rtrim(pj.job_information1))) and
5844 upper(ltrim(rtrim(pj.job_information_category))) = 'CA' and
5845 pj.job_id=paf.job_id and
5846 paf.primary_flag = 'Y' and
5847 --l_year_end between
5848 -- ppf.effective_start_date and
5849 -- ppf.effective_end_date and
5850 ppf.start_date between
5851 paf.effective_start_date and
5852 paf.effective_end_date and
5853 (paf.employment_category is null OR
5854 substr(paf.employment_category,1,2) not in ('FR','PR','PT')) and
5855 paf.person_id=ppf.person_id and
5856 ppf.effective_start_date < l_year_end and
5857 ppf.effective_end_date > l_year_start and
5858 --l_year_end between
5859 -- ppf.effective_start_date and
5860 -- ppf.effective_end_date and
5861 ppf.person_type_id=ppt.person_type_id and
5862 upper(ltrim(rtrim(ppt.system_person_type)))='EMP' and
5863 ppf.business_group_id=p_business_group_id and
5864 paf.location_id=hl1.location_id and
5865 hl1.region_1=hl2.lookup_code and
5866 hl2.lookup_type='CA_PROVINCE' and
5867 pert.request_id=p_request_id and
5868 hl2.meaning=pert.segment2 and
5869 --pert.segment4 = 'Y' and
5870 pert.context='FORM14' and
5871 pert.segment1='PROVINCE' and
5872 (
5873 (
5874 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
5875 hsck.segment6 is not null and
5876 hsck.segment6 = v_naic_code
5877 )
5878 OR
5879 (
5880 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
5881 hsck.segment6 is null and
5882 hsck.segment1 in (select segment3
5883 from per_ca_ee_report_lines
5884 where request_id = p_request_id and
5885 context = 'FORM13' and
5886 segment1 = 'NAIC' and
5887 segment2 = v_naic_code)
5888 )
5889 ) and
5890 pppv.assignment_id = paf.assignment_id and
5891 pppv.approved = 'Y' and
5892 pppv.change_date between l_year_start and
5893 l_year_end and
5894 pppv.proposal_reason =
5895 (
5896 select lookup_code
5897 from hr_lookups
5898 where lookup_type = 'PROPOSAL_REASON' and
5899 upper(meaning) = 'PROMOTION'
5900 )
5901 )
5902 group by province,employment_category,sex
5903 order by province,employment_category,sex;
5904
5905 cursor cur_promotions(desig number) is
5906 select
5907 count(person_id) count,
5908 employment_category employment_category,
5909 sex sex,
5910 province province
5911 from
5912 (
5913 select
5914 paf.person_id person_id,
5915 substr(paf.employment_category,1,2) employment_category,
5916 ppf.sex sex,
5917 hl1.region_1 province
5921 per_assignments_f paf,
5918 from
5919 hr_lookups hl,
5920 per_jobs pj,
5922 per_people_f ppf,
5923 per_person_types ppt,
5924 hr_locations hl1,
5925 per_ca_ee_report_lines pert,
5926 hr_lookups hl2,
5927 hr_soft_coding_keyflex hsck,
5928 per_pay_proposals_v2 pppv
5929 where
5930 upper(ltrim(rtrim(hl.lookup_type)))='EEOG' and
5931 upper(ltrim(rtrim(hl.lookup_code)))
5932 = upper(ltrim(ltrim(pj.job_information1))) and
5933 upper(ltrim(rtrim(pj.job_information_category))) = 'CA' and
5934 pj.job_id=paf.job_id and
5935 paf.primary_flag = 'Y' and
5936 --decode(paf.employment_category,'PT',p_date_tmp_emp,l_year_end) between
5937 -- ppf.effective_start_date and
5938 -- ppf.effective_end_date and
5939 ppf.start_date between
5940 paf.effective_start_date and
5941 paf.effective_end_date and
5942 paf.employment_category is not null and
5943 substr(paf.employment_category,1,2) in ('FR','PR','PT')and
5944 paf.person_id=ppf.person_id and
5945 --decode(paf.employment_category,'PT',p_date_tmp_emp,l_year_end) between
5946 -- ppf.effective_start_date and
5947 -- ppf.effective_end_date and
5948 ppf.effective_start_date < l_year_end and
5949 ppf.effective_end_date > l_year_start and
5950 ppf.person_type_id=ppt.person_type_id and
5951 upper(ltrim(rtrim(ppt.system_person_type)))='EMP' and
5952 ppf.business_group_id=p_business_group_id and
5953 paf.location_id=hl1.location_id and
5954 hl1.region_1=hl2.lookup_code and
5955 hl2.lookup_type='CA_PROVINCE' and
5956 pert.request_id=p_request_id and
5957 hl2.meaning=pert.segment2 and
5958 --pert.segment4 = 'Y' and
5959 pert.context='FORM14' and
5960 pert.segment1='PROVINCE' and
5961 decode(desig,1,per_information5,
5962 2,per_information6,
5963 3,per_information7)='Y' and
5964 (
5965 (
5966 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
5967 hsck.segment6 is not null and
5968 hsck.segment6 = v_naic_code
5969 )
5970 OR
5971 (
5972 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
5973 hsck.segment6 is null and
5974 hsck.segment1 in (select segment3
5975 from per_ca_ee_report_lines
5976 where request_id = p_request_id and
5977 context = 'FORM13' and
5978 segment1 = 'NAIC' and
5979 segment2 = v_naic_code)
5980 )
5981 ) and
5982 pppv.assignment_id = paf.assignment_id and
5983 pppv.change_date between l_year_start and
5984 l_year_end and
5985 pppv.approved = 'Y' and
5986 pppv.proposal_reason =
5987 (
5988 select lookup_code
5989 from hr_lookups
5990 where lookup_type = 'PROPOSAL_REASON' and
5991 upper(meaning) = 'PROMOTION'
5992 )
5993 union all
5994 select
5995 paf.person_id person_id,
5996 'FR' employment_category,
5997 ppf.sex sex,
5998 hl1.region_1 province
5999 from
6000 hr_lookups hl,
6001 per_jobs pj,
6002 per_assignments_f paf,
6003 per_people_f ppf,
6004 per_person_types ppt,
6005 hr_locations hl1,
6006 per_ca_ee_report_lines pert,
6007 hr_lookups hl2,
6008 hr_soft_coding_keyflex hsck,
6009 per_pay_proposals_v2 pppv
6010 where
6011 upper(ltrim(rtrim(hl.lookup_type)))='EEOG' and
6012 upper(ltrim(rtrim(hl.lookup_code)))
6013 = upper(ltrim(ltrim(pj.job_information1))) and
6014 upper(ltrim(rtrim(pj.job_information_category))) = 'CA' and
6015 pj.job_id=paf.job_id and
6016 paf.primary_flag = 'Y' and
6017 --l_year_end between
6018 -- paf.effective_start_date and
6019 -- paf.effective_end_date and
6020 ppf.effective_start_date between
6021 paf.effective_start_date and
6022 paf.effective_end_date and
6023 (paf.employment_category is null OR
6024 substr(paf.employment_category,1,2) not in ('FR','PR','PT'))and
6025 paf.person_id=ppf.person_id and
6026 --l_year_end between
6027 -- ppf.effective_start_date and
6028 -- ppf.effective_end_date and
6029 ppf.effective_start_date < l_year_end and
6030 ppf.effective_end_date > l_year_start and
6031 ppf.person_type_id=ppt.person_type_id and
6032 upper(ltrim(rtrim(ppt.system_person_type)))='EMP' and
6033 ppf.business_group_id=p_business_group_id and
6034 paf.location_id=hl1.location_id and
6035 hl1.region_1=hl2.lookup_code and
6036 hl2.lookup_type='CA_PROVINCE' and
6037 pert.request_id=p_request_id and
6038 hl2.meaning=pert.segment2 and
6039 --pert.segment4 = 'Y' and
6040 pert.context='FORM14' and
6041 pert.segment1='PROVINCE' and
6042 decode(desig,1,per_information5,
6043 2,per_information6,
6044 3,per_information7)='Y' and
6048 hsck.segment6 is not null and
6045 (
6046 (
6047 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
6049 hsck.segment6 = v_naic_code
6050 )
6051 OR
6052 (
6053 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
6054 hsck.segment6 is null and
6055 hsck.segment1 in (select segment3
6056 from per_ca_ee_report_lines
6057 where request_id = p_request_id and
6058 context = 'FORM13' and
6059 segment1 = 'NAIC' and
6060 segment2 = v_naic_code)
6061 )
6062 ) and
6063 pppv.assignment_id = paf.assignment_id and
6064 pppv.approved = 'Y'and
6065 pppv.change_date between l_year_start and
6066 l_year_end and
6067 pppv.proposal_reason =
6068 (
6069 select lookup_code
6070 from hr_lookups
6071 where lookup_type = 'PROPOSAL_REASON' and
6072 upper(meaning) = 'PROMOTION'
6073 )
6074 )
6075 group by province,employment_category,sex
6076 order by province,employment_category,sex;
6077
6078 cursor cur_count_national_promotions is
6079 select
6080 segment3,
6081 sum(to_number(segment4)) segment4,
6082 sum(to_number(segment5)) segment5,
6083 sum(to_number(segment6)) segment6,
6084 sum(to_number(segment7)) segment7,
6085 sum(to_number(segment8)) segment8,
6086 sum(to_number(segment9)) segment9,
6087 sum(to_number(segment10)) segment10,
6088 sum(to_number(segment11)) segment11,
6089 sum(to_number(segment12)) segment12,
6090 sum(to_number(segment13)) segment13,
6091 sum(to_number(segment14)) segment14,
6092 sum(to_number(segment15)) segment15
6093 from
6094 per_ca_ee_report_lines
6095 where
6096 request_id = p_request_id and
6097 context = 'FORM5P' and
6098 segment1 = 'PROVINCE' and
6099 segment21 = v_naic_code
6100 group by segment3;
6101
6102 cursor cur_notfound_promotions(emp_cat number) is
6103 select
6104 segment2,
6105 decode(emp_cat,1,'FR','2','PR',3,'PT') emp_category
6106 from
6107 per_ca_ee_report_lines
6108 where
6109 request_id = p_request_id and
6110 segment3 <> '0' and
6111 context = 'FORM14'
6112 minus
6113 select
6114 segment2,
6115 segment3
6116 from
6117 per_ca_ee_report_lines
6118 where
6119 request_id = p_request_id and
6120 context = 'FORM5P' and
6121 segment1 = 'PROVINCE' ;
6122
6123 begin
6124
6125 for naic in cur_naic loop
6126
6127 v_naic_code := naic.naic_code;
6128
6129 hr_utility.trace('Form5: v_naic = ' || v_naic_code );
6130
6131 for j in cur_promoted_total
6132 loop
6133 v_count := j.count_total;
6134 v_meaning := j.meaning;
6135 v_employment_category := j.employment_category;
6136 v_sex := j.sex;
6137 v_province := j.province;
6138
6139 open cur_meaning;
6140 fetch cur_meaning into v_province_name;
6141 close cur_meaning;
6142
6143 if ((ltrim(rtrim(v_province_name))
6144 <>ltrim(rtrim(prev_province_name))) or
6145 (ltrim(rtrim(prev_meaning)) <> ltrim(rtrim(v_meaning))) or
6146 (ltrim(rtrim(prev_naic_code)) <> ltrim(rtrim(v_naic_code))) or
6147 (ltrim(rtrim(prev_employment_category)) <>
6148 ltrim(rtrim(v_employment_category)))) then
6149
6150 per_ca_ee_extract_pkg.k := per_ca_ee_extract_pkg.k + 1;
6151
6152 insert into per_ca_ee_report_lines
6153 (request_id,
6154 line_number,
6155 context,
6156 segment1,
6157 segment2,
6158 segment3,
6159 segment4,
6160 segment5,
6161 segment6,
6162 segment7,
6163 segment8,
6164 segment9,
6165 segment10,
6166 segment11,
6167 segment12,
6168 segment13,
6169 segment14,
6170 segment15,
6171 segment16,
6172 segment21) values
6173 ( p_request_id,
6174 per_ca_ee_extract_pkg.k,
6175 'FORM5',
6176 'PROVINCE',
6177 v_province_name,
6178 v_meaning,
6179 v_employment_category,
6180 nvl(v_count,0),
6181 decode(v_sex,'F',v_count,0),
6182 decode(v_sex,'M',v_count,0),
6183 '0',
6184 '0',
6185 '0',
6186 '0',
6187 '0',
6188 '0',
6189 '0',
6190 '0',
6191 '0',
6192 v_naic_code);
6193 else
6194
6195 if prev_province_name = v_province_name and
6196 prev_meaning = v_meaning and
6197 prev_naic_code = v_naic_code and
6201 if v_sex = 'M' then
6198 prev_employment_category = v_employment_category and
6199 prev_sex <> v_sex then
6200
6202
6203 update per_ca_ee_report_lines set
6204 segment7=nvl(v_count,0),
6205 segment5=segment5 + nvl(v_count,0)
6206 where request_id=p_request_id and
6207 line_number = per_ca_ee_extract_pkg.k and
6208 context='FORM5' and
6209 segment1='PROVINCE' and
6210 segment2=v_province_name and
6211 segment3=v_meaning and
6212 segment4=v_employment_category and
6213 segment21=v_naic_code;
6214
6215 elsif v_sex = 'F' then
6216
6217 update per_ca_ee_report_lines set
6218 segment6=nvl(v_count,0),
6219 segment5=segment5 + nvl(v_count,0)
6220 where request_id=p_request_id and
6221 line_number = per_ca_ee_extract_pkg.k and
6222 context='FORM5' and
6223 segment1='PROVINCE' and
6224 segment2=v_province_name and
6225 segment3=v_meaning and
6226 segment4=v_employment_category and
6227 segment21=v_naic_code;
6228
6229 end if;
6230
6231 end if;
6232 end if;
6233
6234 prev_meaning := v_meaning;
6235 prev_employment_category := v_employment_category;
6236 prev_sex := v_sex;
6237 prev_province_name := v_province_name;
6238 prev_naic_code := v_naic_code;
6239
6240 end loop; -- End loop cur_promoted_total
6241
6242 for i in 1..3 loop
6243
6244 for j in cur_promoted(i)
6245 loop
6246
6247 v_sex := j.sex;
6248 v_employment_category := j.employment_category;
6249 v_meaning := j.meaning;
6250 v_count := j.count;
6251 v_province := j.province;
6252
6253 open cur_meaning;
6254 fetch cur_meaning into v_province_name;
6255 close cur_meaning;
6256
6257
6258 if i = 1 then
6259
6260 if v_sex = 'M' then
6261
6262 update per_ca_ee_report_lines set
6263 segment8 = nvl(segment8,0) + nvl(v_count,0),
6264 segment10 = nvl(v_count,0)
6265 where
6266 request_id = p_request_id and
6267 context = 'FORM5' and
6268 segment1 = 'PROVINCE' and
6269 segment2 = v_province_name and
6270 segment3 = v_meaning and
6271 segment4 = v_employment_category and
6272 segment21 = v_naic_code;
6273
6274 elsif v_sex = 'F' then
6275
6276 update per_ca_ee_report_lines set
6277 segment8 = nvl(segment8,0) + nvl(v_count,0),
6278 segment9 = nvl(v_count,0)
6279 where
6280 request_id = p_request_id and
6281 context = 'FORM5' and
6282 segment1 = 'PROVINCE' and
6283 segment2 = v_province_name and
6284 segment3 = v_meaning and
6285 segment4 = v_employment_category and
6286 segment21 = v_naic_code;
6287
6288 end if;
6289
6290 elsif i = 2 then
6291
6292 if v_sex = 'M' then
6293
6294 update per_ca_ee_report_lines set
6295 segment11 = nvl(segment11,0) + nvl(v_count,0),
6296 segment13 = nvl(v_count,0)
6297 where
6298 request_id = p_request_id and
6299 context = 'FORM5' and
6300 segment1 = 'PROVINCE' and
6301 segment2 = v_province_name and
6302 segment3 = v_meaning and
6303 segment4 = v_employment_category and
6304 segment21 = v_naic_code;
6305
6306 elsif v_sex = 'F' then
6307
6308 update per_ca_ee_report_lines set
6309 segment11 = nvl(segment11,0) + nvl(v_count,0),
6310 segment12 = 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 end if;
6321
6322 elsif i = 3 then
6323
6324 if v_sex = 'M' then
6325
6326 update per_ca_ee_report_lines set
6327 segment14 = nvl(segment14,0) + nvl(v_count,0),
6328 segment16 = nvl(v_count,0)
6329 where
6330 request_id = p_request_id and
6331 context = 'FORM5' and
6332 segment1 = 'PROVINCE' and
6333 segment2 = v_province_name and
6334 segment3 = v_meaning and
6335 segment4 = v_employment_category and
6339
6336 segment21 = v_naic_code;
6337
6338 elsif v_sex = 'F' then
6340 update per_ca_ee_report_lines set
6341 segment14 = nvl(segment14,0) + nvl(v_count,0),
6342 segment15 = 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 end if;
6353 end if;
6354 end loop; -- End loop cur_hired
6355 end loop; -- End loop Designated Group
6356
6357 for i in cur_eeog loop
6358
6359 v_meaning := i.meaning;
6360
6361 hr_utility.trace('Form5: cur_eeog: v_eeog' || v_meaning);
6362
6363 for emp_cat in 1..3 loop
6364
6365 for x in cur_notfound(emp_cat) loop
6366
6367 per_ca_ee_extract_pkg.k := per_ca_ee_extract_pkg.k + 1;
6368
6369 insert into per_ca_ee_report_lines
6370 (request_id,
6371 line_number,
6372 context,
6373 segment1,
6374 segment2,
6375 segment3,
6376 segment4,
6377 segment5,
6378 segment6,
6379 segment7,
6380 segment8,
6381 segment9,
6382 segment10,
6383 segment11,
6384 segment12,
6385 segment13,
6386 segment14,
6387 segment15,
6388 segment16,
6389 segment21) values
6390 ( p_request_id,
6391 per_ca_ee_extract_pkg.k,
6392 'FORM5',
6393 'PROVINCE',
6394 x.segment2,
6395 v_meaning,
6396 x.emp_category,
6397 0,
6398 0,
6399 0,
6400 0,
6401 0,
6402 0,
6403 0,
6404 0,
6405 0,
6406 0,
6407 0,
6408 0,
6409 v_naic_code);
6410
6411 end loop; -- End loop cur_notfound
6412
6413 end loop; -- End loop emp_cat
6414
6415 end loop; -- End loop cur_eeog
6416
6417 prev_province_name := 'test';
6418 prev_employment_category := 'te';
6419 prev_naic_code := 'te';
6420
6421 for i in cur_total_promotions loop
6422
6423 hr_utility.trace('Form5P: cur_total_promotions');
6424
6425 v_count := i.count_total;
6426 v_employment_category := i.employment_category;
6427 v_sex := i.sex;
6428 v_province := i.province;
6429
6430 open cur_meaning;
6431 fetch cur_meaning into v_province_name;
6432 close cur_meaning;
6433
6434 hr_utility.trace('Form5P: prev_province_name: ' || prev_province_name);
6435 hr_utility.trace('Form5P: v_province_name: ' || v_province_name);
6436 hr_utility.trace('Form5P: prev_naic_code: ' || prev_naic_code);
6437 hr_utility.trace('Form5P: v_naic_code: ' || v_naic_code);
6438 hr_utility.trace('Form5P: prev_emp_category: ' || prev_employment_category);
6439 hr_utility.trace('Form5P: v_emp_category: ' || v_employment_category);
6440
6441 if ((ltrim(rtrim(v_province_name))
6442 <>ltrim(rtrim(prev_province_name))) or
6443 (ltrim(rtrim(prev_naic_code)) <> ltrim(rtrim(v_naic_code))) or
6444 (ltrim(rtrim(prev_employment_category)) <>
6445 ltrim(rtrim(v_employment_category)))) then
6446
6447 hr_utility.trace('Form5P: cur_total_promotions : Inside If');
6448 per_ca_ee_extract_pkg.k := per_ca_ee_extract_pkg.k + 1;
6449
6450 insert into per_ca_ee_report_lines
6451 (request_id,
6452 line_number,
6453 context,
6454 segment1,
6455 segment2,
6456 segment3,
6457 segment4,
6458 segment5,
6459 segment6,
6460 segment7,
6461 segment8,
6462 segment9,
6463 segment10,
6464 segment11,
6465 segment12,
6466 segment13,
6467 segment14,
6468 segment15,
6469 segment21) values
6470 (p_request_id,
6471 per_ca_ee_extract_pkg.k,
6472 'FORM5P',
6473 'PROVINCE',
6474 v_province_name,
6475 v_employment_category,
6476 nvl(v_count,0),
6477 decode(v_sex,'M',v_count,0),
6478 decode(v_sex,'F',v_count,0),
6479 '0',
6480 '0',
6481 '0',
6482 '0',
6483 '0',
6484 '0',
6485 '0',
6486 '0',
6487 '0',
6488 v_naic_code);
6489
6490 else
6491
6492 if prev_province_name = v_province_name and
6493 prev_naic_code = v_naic_code and
6494 prev_employment_category = v_employment_category and
6495 prev_sex <> v_sex then
6496
6497 if v_sex = 'M' then
6498
6499 update per_ca_ee_report_lines set
6503 line_number = per_ca_ee_extract_pkg.k and
6500 segment5=nvl(v_count,0),
6501 segment4=segment4 + nvl(v_count,0)
6502 where request_id=p_request_id and
6504 context='FORM5P' and
6505 segment1='PROVINCE' and
6506 segment2=v_province_name and
6507 segment3=v_employment_category and
6508 segment21=v_naic_code;
6509
6510 elsif v_sex = 'F' then
6511
6512 update per_ca_ee_report_lines set
6513 segment6=nvl(v_count,0),
6514 segment4=segment4 + nvl(v_count,0)
6515 where request_id=p_request_id and
6516 line_number = per_ca_ee_extract_pkg.k and
6517 context='FORM5P' and
6518 segment1='PROVINCE' and
6519 segment2=v_province_name and
6520 segment3=v_employment_category and
6521 segment21=v_naic_code;
6522
6523 end if;
6524
6525 end if;
6526
6527 end if;
6528
6529 prev_meaning := v_meaning;
6530 prev_employment_category := v_employment_category;
6531 prev_sex := v_sex;
6532
6533 end loop; -- End loop cur_total_promotions
6534
6535 for i in 1..3 loop
6536
6537 for j in cur_promotions(i) loop
6538
6539 v_sex := j.sex;
6540 v_employment_category := j.employment_category;
6541 --v_meaning := j.meaning;
6542 v_count := j.count;
6543 v_province := j.province;
6544
6545 open cur_meaning;
6546 fetch cur_meaning into v_province_name;
6547 close cur_meaning;
6548
6549
6550 if i = 1 then
6551
6552 if v_sex = 'M' then
6553
6554 update per_ca_ee_report_lines set
6555 segment7 = nvl(segment7,0) + nvl(v_count,0),
6556 segment8 = nvl(v_count,0)
6557 where
6558 request_id = p_request_id and
6559 context = 'FORM5P' and
6560 segment1 = 'PROVINCE' and
6561 segment2 = v_province_name and
6562 segment3 = v_employment_category and
6563 segment21 = v_naic_code;
6564
6565 elsif v_sex = 'F' then
6566
6567 update per_ca_ee_report_lines set
6568 segment7 = nvl(segment7,0) + nvl(v_count,0),
6569 segment9 = nvl(v_count,0)
6570 where
6571 request_id = p_request_id and
6572 context = 'FORM5P' and
6573 segment1 = 'PROVINCE' and
6574 segment2 = v_province_name and
6575 segment3 = v_employment_category and
6576 segment21 = v_naic_code;
6577
6578 end if;
6579
6580 elsif i = 2 then
6581
6582 if v_sex = 'M' then
6583
6584 update per_ca_ee_report_lines set
6585 segment10 = nvl(segment10,0) + nvl(v_count,0),
6586 segment11 = nvl(v_count,0)
6587 where
6588 request_id = p_request_id and
6589 context = 'FORM5P' and
6590 segment1 = 'PROVINCE' and
6591 segment2 = v_province_name and
6592 segment3 = v_employment_category and
6593 segment21 = v_naic_code;
6594
6595 elsif v_sex = 'F' then
6596
6597 update per_ca_ee_report_lines set
6598 segment10 = nvl(segment10,0) + nvl(v_count,0),
6599 segment12 = nvl(v_count,0)
6600 where
6601 request_id = p_request_id and
6602 context = 'FORM5P' and
6603 segment1 = 'PROVINCE' and
6604 segment2 = v_province_name and
6605 segment3 = v_employment_category and
6606 segment21 = v_naic_code;
6607
6608 end if;
6609
6610 elsif i = 3 then
6611
6612 if v_sex = 'M' then
6613
6614 update per_ca_ee_report_lines set
6615 segment13 = nvl(segment13,0) + nvl(v_count,0),
6616 segment14 = nvl(v_count,0)
6617 where
6618 request_id = p_request_id and
6619 context = 'FORM5P' and
6620 segment1 = 'PROVINCE' and
6621 segment2 = v_province_name and
6622 segment3 = v_employment_category and
6623 segment21 = v_naic_code;
6624
6625 elsif v_sex = 'F' then
6626
6627 update per_ca_ee_report_lines set
6628 segment13 = nvl(segment13,0) + nvl(v_count,0),
6629 segment15 = nvl(v_count,0)
6630 where
6631 request_id = p_request_id and
6632 context = 'FORM5P' and
6633 segment1 = 'PROVINCE' and
6634 segment2 = v_province_name and
6635 segment3 = v_employment_category and
6636 segment21 = v_naic_code;
6637
6638 end if;
6639
6640 end if;
6641
6642 end loop; -- End loop cur_promotions.
6643
6644 end loop; -- End loop for designated group members.
6645
6646 for i in 1..3 loop
6647 for j in cur_notfound_promotions(i) loop
6648
6649 insert into per_ca_ee_report_lines
6650 (request_id,
6651 line_number,
6652 context,
6653 segment1,
6654 segment2,
6655 segment3,
6656 segment4,
6657 segment5,
6658 segment6,
6659 segment7,
6660 segment8,
6661 segment9,
6665 segment13,
6662 segment10,
6663 segment11,
6664 segment12,
6666 segment14,
6667 segment15,
6668 segment21) values
6669 (p_request_id,
6670 per_ca_ee_extract_pkg.k,
6671 'FORM5P',
6672 'PROVINCE',
6673 j.segment2,
6674 j.emp_category,
6675 '0',
6676 '0',
6677 '0',
6678 '0',
6679 '0',
6680 '0',
6681 '0',
6682 '0',
6683 '0',
6684 '0',
6685 '0',
6686 '0',
6687 v_naic_code);
6688
6689 end loop;
6690 end loop; -- End loop for designated group members.
6691
6692 for i in cur_count_national_promotions loop
6693
6694 insert into per_ca_ee_report_lines
6695 (request_id,
6696 line_number,
6697 context,
6698 segment1,
6699 segment2,
6700 segment3,
6701 segment4,
6702 segment5,
6703 segment6,
6704 segment7,
6705 segment8,
6706 segment9,
6707 segment10,
6708 segment11,
6709 segment12,
6710 segment13,
6711 segment14,
6712 segment21) values
6713 (p_request_id,
6714 per_ca_ee_extract_pkg.k,
6715 'FORM5P',
6716 'NATIONAL',
6717 i.segment3,
6718 i.segment4,
6719 i.segment5,
6720 i.segment6,
6721 i.segment7,
6722 i.segment8,
6723 i.segment9,
6724 i.segment10,
6725 i.segment11,
6726 i.segment12,
6727 i.segment13,
6728 i.segment14,
6729 i.segment15,
6730 -- i.segment16,
6731 v_naic_code);
6732
6733 end loop;
6734
6735 for count_national in cur_count_national loop
6736
6737 hr_utility.trace('Form5: cur_count_national. ');
6738
6739 insert into per_ca_ee_report_lines
6740 (request_id,
6741 line_number,
6742 context,
6743 segment1,
6744 segment2,
6745 segment3,
6746 segment4,
6747 segment5,
6748 segment6,
6749 segment7,
6750 segment8,
6751 segment9,
6752 segment10,
6753 segment11,
6754 segment12,
6755 segment13,
6756 segment14,
6757 segment15,
6758 segment21) values
6759 ( p_request_id,
6760 per_ca_ee_extract_pkg.k,
6761 'FORM5',
6762 'NATIONAL',
6763 count_national.segment3,
6764 count_national.segment4,
6765 count_national.segment5,
6766 count_national.segment6,
6767 count_national.segment7,
6768 count_national.segment8,
6769 count_national.segment9,
6770 count_national.segment10,
6771 count_national.segment11,
6772 count_national.segment12,
6773 count_national.segment13,
6774 count_national.segment14,
6775 count_national.segment15,
6776 count_national.segment16,
6777 v_naic_code);
6778
6779 end loop; -- End loop cur_count_total
6780
6781 prev_naic_code := v_naic_code;
6782
6783 end loop; -- End loop cur_naic
6784
6785
6786 return 1;
6787 end;
6788 end form5;
6789 */
6790
6791 function form5(p_business_group_id in number,
6792 p_request_id in number,
6793 p_year in varchar2,
6794 p_date_tmp_emp in date) return number is
6795
6796 l_year_start date;
6797 l_year_end date;
6798
6799 begin
6800
6801 l_year_start := trunc(to_date(p_year,'YYYY'),'Y');
6802 l_year_end := add_months(trunc(to_date(p_year,'YYYY'),'Y'), 12) -1;
6803
6804 declare
6805
6806 cursor cur_naic is
6807 select pert.segment4 naic_code
6808 from per_ca_ee_report_lines pert
6809 where pert.request_id = p_request_id
6810 and pert.context = 'FORM12';
6811
6812 v_naic_code hr_lookups.lookup_code%TYPE;
6813
6814 cursor cur_jobs is
6815 select job_id,
6816 meaning
6817 from per_jobs,
6818 hr_lookups
6819 where lookup_type = 'EEOG'
6820 and upper(ltrim(rtrim(lookup_code)))
6821 =upper(ltrim(rtrim(job_information1)))
6822 and upper(ltrim(rtrim(job_information_category))) = 'CA'
6823 and business_group_id = p_business_group_id;
6824
6825
6826 cursor cur_person_types is
6827 select person_type_id
6828 from per_person_types
6829 where upper(ltrim(rtrim(system_person_type)))='EMP'
6830 and business_group_id = p_business_group_id;
6831
6832 cursor cur_promoted_total(desig number) is
6833 select
6834 sum(employee_total) employee_total,
6835 meaning meaning,
6836 sex sex,
6837 employment_category employment_category,
6838 province province
6839 from
6840 (
6841 select
6842 employee_promotions(paf.assignment_id,
6846 l_year_end,
6843 paf.person_id,
6844 p_business_group_id,
6845 l_year_start,
6847 'Y') employee_total,
6848 job_exists(paf.job_id) meaning,
6849 ppf.sex sex,
6850 substr(paf.employment_category,1,2) employment_category,
6851 hl1.region_1 province
6852 from
6853 per_assignments_f paf,
6854 per_people_f ppf,
6855 hr_locations hl1,
6856 per_ca_ee_report_lines pert,
6857 hr_lookups hl2,
6858 hr_soft_coding_keyflex hsck
6859 where job_exists(paf.job_id) is not null
6860 and paf.primary_flag = 'Y'
6861 and paf.assignment_id =
6862 (select max(pafm.assignment_id) -- This select ensures that
6863 from per_assignments_f pafm -- for rehires only the last
6864 where pafm.person_id = ppf.person_id -- assignment is used
6865 and pafm.primary_flag = 'Y'
6866 and pafm.business_group_id = p_business_group_id)
6867 -- and ppf.start_date between
6868 -- paf.effective_start_date and
6869 -- paf.effective_end_date
6870 and paf.effective_start_date <= l_year_end
6871 and paf.effective_end_date >= l_year_start
6872 and paf.effective_start_date =
6873 (select max(paf_max.effective_start_date) -- The last assignment
6874 from per_assignments_f paf_max -- in the year
6875 where paf_max.assignment_id = paf.assignment_id
6876 and paf_max.primary_flag = 'Y'
6877 and paf_max.effective_start_date <= l_year_end
6878 and paf_max.effective_end_date >= l_year_start
6879 and paf_max.business_group_id = p_business_group_id)
6880 and paf.employment_category is not null
6881 and substr(paf.employment_category,1,2) in ('FR','PR','PT')
6882 and paf.person_id = ppf.person_id
6883 and ppf.effective_start_date <= l_year_end
6884 and ppf.effective_end_date >= l_year_start
6885 and ppf.effective_start_date =
6886 (select max(ppf_max.effective_start_date) -- The last person
6887 from per_people_f ppf_max -- record in the year
6888 where ppf_max.person_id = ppf.person_id
6889 and ppf_max.effective_start_date <= l_year_end
6890 and ppf_max.effective_end_date >= l_year_start
6891 and ppf_max.business_group_id = p_business_group_id
6892 and person_type_exists(ppf_max.person_type_id) is not null)
6893 and person_type_exists(ppf.person_type_id) is not null
6894 and ppf.business_group_id = p_business_group_id
6895 and paf.location_id = hl1.location_id
6896 and hl1.region_1 = hl2.lookup_code
6897 and hl2.lookup_type = 'CA_PROVINCE'
6898 and pert.request_id = p_request_id
6899 and hl2.meaning = pert.segment2
6900 and pert.context = 'FORM14'
6901 and pert.segment1 = 'PROVINCE'
6902 and decode (desig, 0, 'Y',
6903 1, per_information5,
6904 2, per_information6,
6905 3, per_information7) = 'Y'
6906 and (
6907 (
6908 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
6909 hsck.segment6 is not null and
6910 hsck.segment6 = v_naic_code
6911 )
6912 OR
6913 (
6914 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
6915 hsck.segment6 is null and
6916 hsck.segment1 in (select segment3
6917 from per_ca_ee_report_lines
6918 where request_id = p_request_id
6919 and context = 'FORM13'
6920 and segment1 = 'NAIC'
6921 and segment2 = v_naic_code)
6922 )
6923 )
6924 union all
6925 select
6926 employee_promotions(paf.assignment_id,
6927 paf.person_id,
6928 p_business_group_id,
6929 l_year_start,
6930 l_year_end,
6931 'Y') employee_total,
6932 job_exists(paf.job_id) meaning,
6933 ppf.sex sex,
6934 'FR' employment_category,
6935 hl1.region_1 province
6936 from
6937 per_assignments_f paf,
6938 per_people_f ppf,
6939 hr_locations hl1,
6940 per_ca_ee_report_lines pert,
6941 hr_lookups hl2,
6942 hr_soft_coding_keyflex hsck
6943 where
6944 job_exists(paf.job_id) is not null
6945 and paf.primary_flag = 'Y'
6946 and paf.assignment_id =
6947 (select max(pafm.assignment_id) -- This select ensures that
6948 from per_assignments_f pafm -- for rehires only the last
6949 where pafm.person_id = ppf.person_id -- assignment is used
6950 and pafm.primary_flag = 'Y'
6951 and pafm.business_group_id = p_business_group_id)
6952 -- and ppf.start_date between
6953 -- paf.effective_start_date and
6954 -- paf.effective_end_date
6958 (select max(paf_max.effective_start_date)
6955 and paf.effective_start_date <= l_year_end
6956 and paf.effective_end_date >= l_year_start
6957 and paf.effective_start_date =
6959 from per_assignments_f paf_max
6960 where paf_max.assignment_id = paf.assignment_id
6961 and paf_max.primary_flag = 'Y'
6962 and paf_max.effective_start_date <= l_year_end
6963 and paf_max.effective_end_date >= l_year_start
6964 and paf_max.business_group_id = p_business_group_id)
6965 and (paf.employment_category is null OR
6966 substr(paf.employment_category,1,2) not in ('FR','PR','PT'))
6967 and paf.person_id = ppf.person_id
6968 and ppf.effective_start_date <= l_year_end
6969 and ppf.effective_end_date >= l_year_start
6970 and ppf.effective_start_date =
6971 (select max(ppf_max.effective_start_date) -- The last person
6972 from per_people_f ppf_max -- record in the year
6973 where ppf_max.person_id = ppf.person_id
6974 and ppf_max.effective_start_date <= l_year_end
6975 and ppf_max.effective_end_date >= l_year_start
6976 and ppf_max.business_group_id = p_business_group_id
6977 and person_type_exists(ppf_max.person_type_id) is not null)
6978 and person_type_exists(ppf.person_type_id) is not null
6979 and ppf.business_group_id = p_business_group_id
6980 and paf.location_id = hl1.location_id
6981 and hl1.region_1 = hl2.lookup_code
6982 and hl2.lookup_type = 'CA_PROVINCE'
6983 and pert.request_id = p_request_id
6984 and hl2.meaning = pert.segment2
6985 and pert.context = 'FORM14'
6986 and pert.segment1 = 'PROVINCE'
6987 and decode (desig, 0, 'Y',
6988 1, per_information5,
6989 2, per_information6,
6990 3, per_information7) = 'Y'
6991 and
6992 (
6993 (
6994 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
6995 hsck.segment6 is not null and
6996 hsck.segment6 = v_naic_code
6997 )
6998 OR
6999 (
7000 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
7001 hsck.segment6 is null and
7002 hsck.segment1 in
7003 (select segment3
7004 from per_ca_ee_report_lines
7005 where request_id = p_request_id
7006 and context = 'FORM13'
7007 and segment1 = 'NAIC'
7008 and segment2 = v_naic_code)
7009 )
7010 )
7011 )
7012 group by province,meaning,employment_category,sex
7013 order by province,meaning,employment_category,sex;
7014
7015 v_count number(10);
7016 v_meaning hr_lookups.meaning%TYPE;
7017 v_employment_category per_assignments_f.employment_category%TYPE;
7018 v_sex per_people_f.sex%TYPE;
7019 v_province hr_locations.region_1%TYPE;
7020 prev_meaning hr_lookups.meaning%TYPE := 'test';
7021 prev_employment_category per_assignments_f.employment_category%TYPE := 'test';
7022 prev_sex per_people_f.sex%TYPE := 'test';
7023 prev_naic_code hr_lookups.lookup_code%TYPE;
7024
7025 cursor cur_meaning is
7026 select meaning
7027 from hr_lookups
7028 where upper(ltrim(rtrim(lookup_type)))='CA_PROVINCE'
7029 and upper(ltrim(rtrim(lookup_code)))=upper(ltrim(rtrim(v_province)));
7030
7031 v_province_name hr_lookups.meaning%TYPE;
7032 prev_province_name hr_lookups.meaning%TYPE;
7033
7034 cursor cur_eeog is
7035 select meaning
7036 from hr_lookups
7037 where lookup_type='EEOG';
7038
7039 cursor cur_notfound(p_emp_cat number) is
7040 select
7041 segment2,
7042 v_meaning,
7043 decode(p_emp_cat,1,'FR',2,'PR',3,'PT') emp_category
7044 from
7045 per_ca_ee_report_lines where
7046 request_id=p_request_id and
7047 context='FORM14' and
7048 segment1='PROVINCE' and
7049 segment3 <> '0'
7050 minus
7051 select
7052 segment2,
7053 segment3,
7054 segment4
7055 from
7056 per_ca_ee_report_lines
7057 where
7058 request_id=p_request_id and
7059 context='FORM5' and
7060 segment1='PROVINCE'and
7061 segment21 = v_naic_code;
7062
7063 cursor cur_count_national is
7064 select
7065 segment3,
7066 segment4,
7067 sum(to_number(segment5)) segment5,
7068 sum(to_number(segment6)) segment6,
7069 sum(to_number(segment7)) segment7,
7070 sum(to_number(segment8)) segment8,
7071 sum(to_number(segment9)) segment9,
7072 sum(to_number(segment10)) segment10,
7073 sum(to_number(segment11)) segment11,
7074 sum(to_number(segment12)) segment12,
7075 sum(to_number(segment13)) segment13,
7076 sum(to_number(segment14)) segment14,
7077 sum(to_number(segment15)) segment15,
7081 where
7078 sum(to_number(segment16)) segment16
7079 from
7080 per_ca_ee_report_lines
7082 request_id = p_request_id and
7083 context = 'FORM5' and
7084 segment1 = 'PROVINCE' and
7085 segment21 = v_naic_code
7086 group by segment3,segment4;
7087
7088 cursor cur_total_promotions(desig number) is
7089 select
7090 sum(promotion_total) promotion_total,
7091 sex sex,
7092 employment_category employment_category,
7093 province province
7094 from
7095 (
7096 select
7097 employee_promotions(paf.assignment_id,
7098 paf.person_id,
7099 p_business_group_id,
7100 l_year_start,
7101 l_year_end,
7102 'N') promotion_total,
7103 ppf.sex sex,
7104 substr(paf.employment_category,1,2) employment_category,
7105 hl1.region_1 province
7106 from
7107 per_assignments_f paf,
7108 per_people_f ppf,
7109 hr_locations hl1,
7110 per_ca_ee_report_lines pert,
7111 hr_lookups hl2,
7112 hr_soft_coding_keyflex hsck
7113 where
7114 job_exists(paf.job_id) is not null
7115 and paf.primary_flag = 'Y'
7116 and paf.assignment_id =
7117 (select max(pafm.assignment_id) -- This select ensures that
7118 from per_assignments_f pafm -- for rehires only the last
7119 where pafm.person_id = ppf.person_id -- assignment is used
7120 and pafm.primary_flag = 'Y'
7121 and pafm.business_group_id = p_business_group_id)
7122 -- ppf.start_date between
7123 -- paf.effective_start_date and
7124 -- paf.effective_end_date and
7125 and paf.effective_start_date <= l_year_end
7126 and paf.effective_end_date >= l_year_start
7127 and paf.effective_start_date =
7128 (select max(paf_max.effective_start_date)
7129 from per_assignments_f paf_max
7130 where paf_max.assignment_id = paf.assignment_id
7131 and paf_max.primary_flag = 'Y'
7132 and paf_max.effective_start_date <= l_year_end
7133 and paf_max.effective_end_date >= l_year_start
7134 and paf_max.business_group_id = p_business_group_id)
7135 and paf.employment_category is not null
7136 and substr(paf.employment_category,1,2) in ('FR','PR','PT')
7137 and paf.person_id=ppf.person_id
7138 and ppf.effective_start_date <= l_year_end
7139 and ppf.effective_end_date >= l_year_start
7140 and ppf.effective_start_date =
7141 (select max(ppf_max.effective_start_date) -- The last person
7142 from per_people_f ppf_max -- record in the year
7143 where ppf_max.person_id = ppf.person_id
7144 and ppf_max.effective_start_date <= l_year_end
7145 and ppf_max.effective_end_date >= l_year_start
7146 and ppf_max.business_group_id = p_business_group_id
7147 and person_type_exists(ppf_max.person_type_id) is not null)
7148 and person_type_exists(ppf.person_type_id) is not null
7149 and ppf.business_group_id=p_business_group_id
7150 and paf.location_id=hl1.location_id
7151 and hl1.region_1=hl2.lookup_code
7152 and hl2.lookup_type='CA_PROVINCE'
7153 and pert.request_id=p_request_id
7154 and hl2.meaning=pert.segment2
7155 and pert.context='FORM14'
7156 and pert.segment1='PROVINCE'
7157 and decode (desig, 0, 'Y',
7158 1, per_information5,
7159 2, per_information6,
7160 3, per_information7) = 'Y'
7161 and (
7162 (
7163 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
7164 hsck.segment6 is not null and
7165 hsck.segment6 = v_naic_code
7166 )
7167 OR
7168 (
7169 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
7170 hsck.segment6 is null and
7171 hsck.segment1 in (select segment3
7172 from per_ca_ee_report_lines
7173 where request_id = p_request_id and
7174 context = 'FORM13' and
7175 segment1 = 'NAIC' and
7176 segment2 = v_naic_code)
7177 )
7178 )
7179 union all
7180 select
7181 employee_promotions(paf.assignment_id,
7182 paf.person_id,
7183 p_business_group_id,
7184 l_year_start,
7185 l_year_end,
7186 'N') promotion_total,
7187 ppf.sex sex,
7188 'FR' employment_category,
7189 hl1.region_1 province
7190 from
7191 per_assignments_f paf,
7192 per_people_f ppf,
7193 hr_locations hl1,
7197 where
7194 per_ca_ee_report_lines pert,
7195 hr_lookups hl2,
7196 hr_soft_coding_keyflex hsck
7198 job_exists(paf.job_id) is not null
7199 and paf.primary_flag = 'Y'
7200 and paf.assignment_id =
7201 (select max(pafm.assignment_id) -- This select ensures that
7202 from per_assignments_f pafm -- for rehires only the last
7203 where pafm.person_id = ppf.person_id -- assignment is used
7204 and pafm.primary_flag = 'Y'
7205 and pafm.business_group_id = p_business_group_id)
7206 -- ppf.start_date between
7207 -- paf.effective_start_date and
7208 -- paf.effective_end_date and
7209 and paf.effective_start_date <= l_year_end
7210 and paf.effective_end_date >= l_year_start
7211 and paf.effective_start_date =
7212 (select max(paf_max.effective_start_date)
7213 from per_assignments_f paf_max
7214 where paf_max.assignment_id = paf.assignment_id
7215 and paf_max.primary_flag = 'Y'
7216 and paf_max.effective_start_date <= l_year_end
7217 and paf_max.effective_end_date >= l_year_start
7218 and paf_max.business_group_id = p_business_group_id)
7219 and (paf.employment_category is null OR
7220 substr(paf.employment_category,1,2) not in ('FR','PR','PT'))
7221 and paf.person_id=ppf.person_id
7222 and ppf.effective_start_date <= l_year_end
7223 and ppf.effective_end_date >= l_year_start
7224 and ppf.effective_start_date =
7225 (select max(ppf_max.effective_start_date) -- The last person
7226 from per_people_f ppf_max -- record in the year
7227 where ppf_max.person_id = ppf.person_id
7228 and ppf_max.effective_start_date <= l_year_end
7229 and ppf_max.effective_end_date >= l_year_start
7230 and ppf_max.business_group_id = p_business_group_id
7231 and person_type_exists(ppf_max.person_type_id) is not null)
7232 and person_type_exists(ppf.person_type_id) is not null
7233 and ppf.business_group_id=p_business_group_id
7234 and paf.location_id=hl1.location_id
7235 and hl1.region_1=hl2.lookup_code
7236 and hl2.lookup_type='CA_PROVINCE'
7237 and pert.request_id=p_request_id
7238 and hl2.meaning=pert.segment2
7239 and pert.context='FORM14'
7240 and pert.segment1='PROVINCE'
7241 and decode (desig, 0, 'Y',
7242 1, per_information5,
7243 2, per_information6,
7244 3, per_information7) = 'Y'
7245 and
7246 (
7247 (
7248 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
7249 hsck.segment6 is not null and
7250 hsck.segment6 = v_naic_code
7251 )
7252 OR
7253 (
7254 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
7255 hsck.segment6 is null and
7256 hsck.segment1 in
7257 (select segment3
7258 from per_ca_ee_report_lines
7259 where request_id = p_request_id
7260 and context = 'FORM13'
7261 and segment1 = 'NAIC'
7262 and segment2 = v_naic_code)
7263 )
7264 )
7265 )
7266 group by province,employment_category,sex
7267 order by province,employment_category,sex;
7268
7269 cursor cur_count_national_promotions is
7270 select
7271 segment3,
7272 sum(to_number(segment4)) segment4,
7273 sum(to_number(segment5)) segment5,
7274 sum(to_number(segment6)) segment6,
7275 sum(to_number(segment7)) segment7,
7276 sum(to_number(segment8)) segment8,
7277 sum(to_number(segment9)) segment9,
7278 sum(to_number(segment10)) segment10,
7279 sum(to_number(segment11)) segment11,
7280 sum(to_number(segment12)) segment12,
7281 sum(to_number(segment13)) segment13,
7282 sum(to_number(segment14)) segment14,
7283 sum(to_number(segment15)) segment15
7284 from
7285 per_ca_ee_report_lines
7286 where
7287 request_id = p_request_id and
7288 context = 'FORM5P' and
7289 segment1 = 'PROVINCE' and
7290 segment21 = v_naic_code
7291 group by segment3;
7292
7293 cursor cur_notfound_promotions(emp_cat number) is
7294 select
7295 segment2,
7296 decode(emp_cat,1,'FR','2','PR',3,'PT') emp_category
7297 from
7298 per_ca_ee_report_lines
7299 where
7300 request_id = p_request_id and
7301 segment3 <> '0' and
7302 context = 'FORM14'
7303 minus
7304 select
7305 segment2,
7306 segment3
7307 from
7308 per_ca_ee_report_lines
7309 where
7310 request_id = p_request_id and
7311 context = 'FORM5P' and
7312 segment1 = 'PROVINCE' ;
7313
7314 begin
7315
7316 /* Caching data from per_jobs and per_person_types tables */
7317
7318 open cur_jobs;
7319 fetch cur_jobs bulk collect into
7320 v_job_id_temp,
7321 v_job_temp;
7322
7323 close cur_jobs;
7324
7325 if v_job_id_temp.count > 0 then
7329 end loop;
7326 for i in v_job_id_temp.first..v_job_id_temp.last LOOP
7327 v_job_id(v_job_id_temp(i)) := v_job_id_temp(i);
7328 v_job(v_job_id_temp(i)) := v_job_temp(i);
7330 end if;
7331
7332 open cur_person_types;
7333 fetch cur_person_types bulk collect into
7334 v_person_type_temp;
7335
7336 close cur_person_types;
7337
7338 if v_person_type_temp.count > 0 then
7339 for i in v_person_type_temp.first..v_person_type_temp.last LOOP
7340 v_person_type(v_person_type_temp(i)) := v_person_type_temp(i);
7341 end loop;
7342 end if;
7343
7344 for naic in cur_naic loop
7345
7346 v_naic_code := naic.naic_code;
7347
7348 hr_utility.trace('Form5: v_naic = ' || v_naic_code );
7349
7350 for i in 0..3 loop
7351
7352 for j in cur_promoted_total(i)
7353 loop
7354 v_count := j.employee_total;
7355 v_meaning := j.meaning;
7356 v_employment_category := j.employment_category;
7357 v_sex := j.sex;
7358 v_province := j.province;
7359
7360 open cur_meaning;
7361 fetch cur_meaning into v_province_name;
7362 close cur_meaning;
7363
7364 if v_count <> 0 then -- Only employees who have been promoted
7365
7366 if i = 0 then
7367
7368 if ((ltrim(rtrim(v_province_name))
7369 <>ltrim(rtrim(prev_province_name))) or
7370 (ltrim(rtrim(prev_meaning)) <> ltrim(rtrim(v_meaning))) or
7371 (ltrim(rtrim(prev_naic_code)) <> ltrim(rtrim(v_naic_code))) or
7372 (ltrim(rtrim(prev_employment_category)) <>
7373 ltrim(rtrim(v_employment_category)))) then
7374
7375 per_ca_ee_extract_pkg.k := per_ca_ee_extract_pkg.k + 1;
7376
7377 insert into per_ca_ee_report_lines
7378 (request_id,
7379 line_number,
7380 context,
7381 segment1,
7382 segment2,
7383 segment3,
7384 segment4,
7385 segment5,
7386 segment6,
7387 segment7,
7388 segment8,
7389 segment9,
7390 segment10,
7391 segment11,
7392 segment12,
7393 segment13,
7394 segment14,
7395 segment15,
7396 segment16,
7397 segment21) values
7398 ( p_request_id,
7399 per_ca_ee_extract_pkg.k,
7400 'FORM5',
7401 'PROVINCE',
7402 v_province_name,
7403 v_meaning,
7404 v_employment_category,
7405 nvl(v_count,0),
7406 decode(v_sex,'F',v_count,0),
7407 decode(v_sex,'M',v_count,0),
7408 '0',
7409 '0',
7410 '0',
7411 '0',
7412 '0',
7413 '0',
7414 '0',
7415 '0',
7416 '0',
7417 v_naic_code);
7418 else
7419
7420 if prev_province_name = v_province_name and
7421 prev_meaning = v_meaning and
7422 prev_naic_code = v_naic_code and
7423 prev_employment_category = v_employment_category and
7424 prev_sex <> v_sex then
7425
7426 if v_sex = 'M' then
7427
7428 update per_ca_ee_report_lines set
7429 segment7=nvl(v_count,0),
7430 segment5=segment5 + nvl(v_count,0)
7431 where request_id=p_request_id and
7432 line_number = per_ca_ee_extract_pkg.k and
7433 context='FORM5' and
7434 segment1='PROVINCE' and
7435 segment2=v_province_name and
7436 segment3=v_meaning and
7437 segment4=v_employment_category and
7438 segment21=v_naic_code;
7439
7440 elsif v_sex = 'F' then
7441
7442 update per_ca_ee_report_lines set
7443 segment6=nvl(v_count,0),
7444 segment5=segment5 + nvl(v_count,0)
7445 where request_id=p_request_id and
7446 line_number = per_ca_ee_extract_pkg.k and
7447 context='FORM5' and
7448 segment1='PROVINCE' and
7449 segment2=v_province_name and
7450 segment3=v_meaning and
7451 segment4=v_employment_category and
7452 segment21=v_naic_code;
7453
7454 end if;
7455
7456 end if;
7457 end if;
7458
7459 prev_meaning := v_meaning;
7463 prev_naic_code := v_naic_code;
7460 prev_employment_category := v_employment_category;
7461 prev_sex := v_sex;
7462 prev_province_name := v_province_name;
7464
7465 elsif i = 1 then
7466
7467 if v_sex = 'M' then
7468
7469 update per_ca_ee_report_lines set
7470 segment8 = nvl(segment8,0) + nvl(v_count,0),
7471 segment10 = nvl(v_count,0)
7472 where
7473 request_id = p_request_id and
7474 context = 'FORM5' and
7475 segment1 = 'PROVINCE' and
7476 segment2 = v_province_name and
7477 segment3 = v_meaning and
7478 segment4 = v_employment_category and
7479 segment21 = v_naic_code;
7480
7481 elsif v_sex = 'F' then
7482
7483 update per_ca_ee_report_lines set
7484 segment8 = nvl(segment8,0) + nvl(v_count,0),
7485 segment9 = nvl(v_count,0)
7486 where
7487 request_id = p_request_id and
7488 context = 'FORM5' and
7489 segment1 = 'PROVINCE' and
7490 segment2 = v_province_name and
7491 segment3 = v_meaning and
7492 segment4 = v_employment_category and
7493 segment21 = v_naic_code;
7494
7495 end if;
7496
7497 elsif i = 2 then
7498
7499 if v_sex = 'M' then
7500
7501 update per_ca_ee_report_lines set
7502 segment11 = nvl(segment11,0) + nvl(v_count,0),
7503 segment13 = nvl(v_count,0)
7504 where
7505 request_id = p_request_id and
7506 context = 'FORM5' and
7507 segment1 = 'PROVINCE' and
7508 segment2 = v_province_name and
7509 segment3 = v_meaning and
7510 segment4 = v_employment_category and
7511 segment21 = v_naic_code;
7512
7513 elsif v_sex = 'F' then
7514
7515 update per_ca_ee_report_lines set
7516 segment11 = nvl(segment11,0) + nvl(v_count,0),
7517 segment12 = 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 end if;
7528
7529 elsif i = 3 then
7530
7531 if v_sex = 'M' then
7532
7533 update per_ca_ee_report_lines set
7534 segment14 = nvl(segment14,0) + nvl(v_count,0),
7535 segment16 = nvl(v_count,0)
7536 where
7537 request_id = p_request_id and
7538 context = 'FORM5' and
7539 segment1 = 'PROVINCE' and
7540 segment2 = v_province_name and
7541 segment3 = v_meaning and
7542 segment4 = v_employment_category and
7543 segment21 = v_naic_code;
7544
7545 elsif v_sex = 'F' then
7546
7547 update per_ca_ee_report_lines set
7548 segment14 = nvl(segment14,0) + nvl(v_count,0),
7549 segment15 = 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 end if;
7560 end if;
7561 end if;
7562 end loop; -- End loop cur_promoted_total
7563 end loop; -- End loop Designated Group
7564
7565 for i in cur_eeog loop
7566
7567 v_meaning := i.meaning;
7568
7569 hr_utility.trace('Form5: cur_eeog: v_eeog' || v_meaning);
7570
7571 for emp_cat in 1..3 loop
7572
7573 for x in cur_notfound(emp_cat) loop
7574
7575 per_ca_ee_extract_pkg.k := per_ca_ee_extract_pkg.k + 1;
7576
7577 insert into per_ca_ee_report_lines
7578 (request_id,
7579 line_number,
7580 context,
7581 segment1,
7582 segment2,
7583 segment3,
7584 segment4,
7585 segment5,
7586 segment6,
7587 segment7,
7588 segment8,
7589 segment9,
7590 segment10,
7591 segment11,
7592 segment12,
7593 segment13,
7594 segment14,
7595 segment15,
7599 per_ca_ee_extract_pkg.k,
7596 segment16,
7597 segment21) values
7598 ( p_request_id,
7600 'FORM5',
7601 'PROVINCE',
7602 x.segment2,
7603 v_meaning,
7604 x.emp_category,
7605 0,
7606 0,
7607 0,
7608 0,
7609 0,
7610 0,
7611 0,
7612 0,
7613 0,
7614 0,
7615 0,
7616 0,
7617 v_naic_code);
7618
7619 end loop; -- End loop cur_notfound
7620
7621 end loop; -- End loop emp_cat
7622
7623 end loop; -- End loop cur_eeog
7624
7625 prev_province_name := 'test';
7626 prev_employment_category := 'te';
7627 prev_naic_code := 'te';
7628
7629 for i in 0..3 loop
7630
7631 for j in cur_total_promotions(i) loop
7632
7633 hr_utility.trace('Form5P: cur_total_promotions');
7634
7635 v_count := j.promotion_total;
7636 v_employment_category := j.employment_category;
7637 v_sex := j.sex;
7638 v_province := j.province;
7639
7640 open cur_meaning;
7641 fetch cur_meaning into v_province_name;
7642 close cur_meaning;
7643
7644 if v_count <> 0 then -- Only process when promotions exist
7645
7646 if i = 0 then
7647
7648 hr_utility.trace('Form5P: prev_province_name: ' || prev_province_name);
7649 hr_utility.trace('Form5P: v_province_name: ' || v_province_name);
7650 hr_utility.trace('Form5P: prev_naic_code: ' || prev_naic_code);
7651 hr_utility.trace('Form5P: v_naic_code: ' || v_naic_code);
7652 hr_utility.trace('Form5P: prev_emp_category: ' || prev_employment_category);
7653 hr_utility.trace('Form5P: v_emp_category: ' || v_employment_category);
7654
7655 if ((ltrim(rtrim(v_province_name))
7656 <>ltrim(rtrim(prev_province_name))) or
7657 (ltrim(rtrim(prev_naic_code)) <> ltrim(rtrim(v_naic_code))) or
7658 (ltrim(rtrim(prev_employment_category)) <>
7659 ltrim(rtrim(v_employment_category)))) then
7660
7661 hr_utility.trace('Form5P: cur_total_promotions : Inside If');
7662 per_ca_ee_extract_pkg.k := per_ca_ee_extract_pkg.k + 1;
7663
7664 insert into per_ca_ee_report_lines
7665 (request_id,
7666 line_number,
7667 context,
7668 segment1,
7669 segment2,
7670 segment3,
7671 segment4,
7672 segment5,
7673 segment6,
7674 segment7,
7675 segment8,
7676 segment9,
7677 segment10,
7678 segment11,
7679 segment12,
7680 segment13,
7681 segment14,
7682 segment15,
7683 segment21) values
7684 (p_request_id,
7685 per_ca_ee_extract_pkg.k,
7686 'FORM5P',
7687 'PROVINCE',
7688 v_province_name,
7689 v_employment_category,
7690 nvl(v_count,0),
7691 decode(v_sex,'M',v_count,0),
7692 decode(v_sex,'F',v_count,0),
7693 '0',
7694 '0',
7695 '0',
7696 '0',
7697 '0',
7698 '0',
7699 '0',
7700 '0',
7701 '0',
7702 v_naic_code);
7703
7704 else
7705
7706 if prev_province_name = v_province_name and
7707 prev_naic_code = v_naic_code and
7708 prev_employment_category = v_employment_category and
7709 prev_sex <> v_sex then
7710
7711 if v_sex = 'M' then
7712
7713 update per_ca_ee_report_lines set
7714 segment5=nvl(v_count,0),
7715 segment4=segment4 + nvl(v_count,0)
7716 where request_id=p_request_id and
7717 line_number = per_ca_ee_extract_pkg.k and
7718 context='FORM5P' and
7719 segment1='PROVINCE' and
7720 segment2=v_province_name and
7721 segment3=v_employment_category and
7722 segment21=v_naic_code;
7723
7724 elsif v_sex = 'F' then
7725
7726 update per_ca_ee_report_lines set
7727 segment6=nvl(v_count,0),
7728 segment4=segment4 + nvl(v_count,0)
7729 where request_id=p_request_id and
7730 line_number = per_ca_ee_extract_pkg.k and
7731 context='FORM5P' and
7732 segment1='PROVINCE' and
7733 segment2=v_province_name and
7734 segment3=v_employment_category and
7735 segment21=v_naic_code;
7736
7737 end if;
7738
7739 end if;
7740
7744 prev_naic_code := v_naic_code;
7741 end if;
7742
7743 prev_province_name := v_province_name;
7745 prev_employment_category := v_employment_category;
7746 prev_sex := v_sex;
7747
7748 elsif i = 1 then
7749
7750
7751 if v_sex = 'M' then
7752
7753 update per_ca_ee_report_lines set
7754 segment7 = nvl(segment7,0) + nvl(v_count,0),
7755 segment8 = nvl(v_count,0)
7756 where
7757 request_id = p_request_id and
7758 context = 'FORM5P' and
7759 segment1 = 'PROVINCE' and
7760 segment2 = v_province_name and
7761 segment3 = v_employment_category and
7762 segment21 = v_naic_code;
7763
7764 elsif v_sex = 'F' then
7765
7766 update per_ca_ee_report_lines set
7767 segment7 = nvl(segment7,0) + nvl(v_count,0),
7768 segment9 = nvl(v_count,0)
7769 where
7770 request_id = p_request_id and
7771 context = 'FORM5P' and
7772 segment1 = 'PROVINCE' and
7773 segment2 = v_province_name and
7774 segment3 = v_employment_category and
7775 segment21 = v_naic_code;
7776
7777 end if;
7778
7779 elsif i = 2 then
7780
7781 if v_sex = 'M' then
7782
7783 update per_ca_ee_report_lines set
7784 segment10 = nvl(segment10,0) + nvl(v_count,0),
7785 segment11 = nvl(v_count,0)
7786 where
7787 request_id = p_request_id and
7788 context = 'FORM5P' and
7789 segment1 = 'PROVINCE' and
7790 segment2 = v_province_name and
7791 segment3 = v_employment_category and
7792 segment21 = v_naic_code;
7793
7794 elsif v_sex = 'F' then
7795
7796 update per_ca_ee_report_lines set
7797 segment10 = nvl(segment10,0) + nvl(v_count,0),
7798 segment12 = nvl(v_count,0)
7799 where
7800 request_id = p_request_id and
7801 context = 'FORM5P' and
7802 segment1 = 'PROVINCE' and
7803 segment2 = v_province_name and
7804 segment3 = v_employment_category and
7805 segment21 = v_naic_code;
7806
7807 end if;
7808
7809 elsif i = 3 then
7810
7811 if v_sex = 'M' then
7812
7813 update per_ca_ee_report_lines set
7814 segment13 = nvl(segment13,0) + nvl(v_count,0),
7815 segment14 = nvl(v_count,0)
7816 where
7817 request_id = p_request_id and
7818 context = 'FORM5P' and
7819 segment1 = 'PROVINCE' and
7820 segment2 = v_province_name and
7821 segment3 = v_employment_category and
7822 segment21 = v_naic_code;
7823
7824 elsif v_sex = 'F' then
7825
7826 update per_ca_ee_report_lines set
7827 segment13 = nvl(segment13,0) + nvl(v_count,0),
7828 segment15 = nvl(v_count,0)
7829 where
7830 request_id = p_request_id and
7831 context = 'FORM5P' and
7832 segment1 = 'PROVINCE' and
7833 segment2 = v_province_name and
7834 segment3 = v_employment_category and
7835 segment21 = v_naic_code;
7836
7837 end if;
7838
7839 end if;
7840 end if;
7841 end loop; -- End loop cur_total_promotions
7842 end loop; -- End loop for designated group members.
7843
7844 for i in 1..3 loop
7845 for j in cur_notfound_promotions(i) loop
7846
7847 insert into per_ca_ee_report_lines
7848 (request_id,
7849 line_number,
7850 context,
7851 segment1,
7852 segment2,
7853 segment3,
7854 segment4,
7855 segment5,
7856 segment6,
7857 segment7,
7858 segment8,
7859 segment9,
7860 segment10,
7861 segment11,
7862 segment12,
7863 segment13,
7864 segment14,
7865 segment15,
7866 segment21) values
7867 (p_request_id,
7868 per_ca_ee_extract_pkg.k,
7869 'FORM5P',
7870 'PROVINCE',
7871 j.segment2,
7872 j.emp_category,
7873 '0',
7874 '0',
7875 '0',
7876 '0',
7877 '0',
7878 '0',
7879 '0',
7880 '0',
7881 '0',
7882 '0',
7883 '0',
7884 '0',
7885 v_naic_code);
7886
7887 end loop;
7888 end loop; -- End loop for designated group members.
7889
7890 for i in cur_count_national_promotions loop
7891
7892 insert into per_ca_ee_report_lines
7893 (request_id,
7894 line_number,
7895 context,
7896 segment1,
7897 segment2,
7898 segment3,
7899 segment4,
7900 segment5,
7901 segment6,
7902 segment7,
7903 segment8,
7904 segment9,
7905 segment10,
7906 segment11,
7907 segment12,
7908 segment13,
7909 segment14,
7910 segment21) values
7911 (p_request_id,
7912 per_ca_ee_extract_pkg.k,
7913 'FORM5P',
7914 'NATIONAL',
7918 i.segment6,
7915 i.segment3,
7916 i.segment4,
7917 i.segment5,
7919 i.segment7,
7920 i.segment8,
7921 i.segment9,
7922 i.segment10,
7923 i.segment11,
7924 i.segment12,
7925 i.segment13,
7926 i.segment14,
7927 i.segment15,
7928 v_naic_code);
7929
7930 end loop;
7931
7932 for count_national in cur_count_national loop
7933
7934 hr_utility.trace('Form5: cur_count_national. ');
7935
7936 insert into per_ca_ee_report_lines
7937 (request_id,
7938 line_number,
7939 context,
7940 segment1,
7941 segment2,
7942 segment3,
7943 segment4,
7944 segment5,
7945 segment6,
7946 segment7,
7947 segment8,
7948 segment9,
7949 segment10,
7950 segment11,
7951 segment12,
7952 segment13,
7953 segment14,
7954 segment15,
7955 segment21) values
7956 ( p_request_id,
7957 per_ca_ee_extract_pkg.k,
7958 'FORM5',
7959 'NATIONAL',
7960 count_national.segment3,
7961 count_national.segment4,
7962 count_national.segment5,
7963 count_national.segment6,
7964 count_national.segment7,
7965 count_national.segment8,
7966 count_national.segment9,
7967 count_national.segment10,
7968 count_national.segment11,
7969 count_national.segment12,
7970 count_national.segment13,
7971 count_national.segment14,
7972 count_national.segment15,
7973 count_national.segment16,
7974 v_naic_code);
7975
7976 end loop; -- End loop cur_count_national
7977
7978 prev_naic_code := v_naic_code;
7979
7980 end loop; -- End loop cur_naic
7981
7982 return 1;
7983
7984 end;
7985 end form5;
7986
7987 function form6(p_business_group_id in number,
7988 p_request_id in number,
7989 p_year in varchar2,
7990 p_date_tmp_emp in date) return number is
7991
7992 l_year_start date;
7993 l_year_end date;
7994
7995 begin
7996
7997 l_year_start := trunc(to_date(p_year,'YYYY'),'Y');
7998 l_year_end := add_months(trunc(to_date(p_year,'YYYY'),'Y'), 12) -1;
7999
8000 declare
8001
8002 cursor cur_naic is
8003 select
8004 pert.segment4 naic_code
8005 from
8006 per_ca_ee_report_lines pert
8007 where
8008 pert.request_id = p_request_id and
8009 pert.context = 'FORM12';
8010
8011 v_naic_code hr_lookups.lookup_code%TYPE;
8012
8013 cursor cur_terminated_total is
8014 select
8015 count(distinct count_total) count_total,
8016 meaning meaning,
8017 sex sex,
8018 employment_category employment_category,
8019 region_1 region_1
8020 from
8021 (
8022 select
8023 paf.person_id count_total,
8024 hl.meaning meaning,
8025 ppf.sex sex,
8026 substr(paf.employment_category,1,2) employment_category,
8027 hl1.region_1 region_1
8028 from
8029 hr_lookups hl,
8030 per_jobs pj,
8031 per_assignments_f paf,
8032 per_people_f ppf,
8033 per_person_types ppt,
8034 per_periods_of_service ppos,
8038 hl.lookup_type='EEOG' and
8035 hr_locations hl1,
8036 hr_soft_coding_keyflex hsck
8037 where
8039 upper(ltrim(rtrim(hl.lookup_code)))
8040 = upper(ltrim(rtrim(pj.job_information1))) and
8041 upper(ltrim(rtrim(pj.job_information_category))) = 'CA' and
8042 pj.job_id=paf.job_id and
8043 paf.primary_flag = 'Y' and
8044 paf.employment_category is not null and
8045 substr(paf.employment_category,1,2) in ('FR','PR','PT') and
8046 --decode(paf.employment_category,'PT',p_date_tmp_emp,l_year_end) between
8047 ppos.actual_termination_date between
8048 paf.effective_start_date and
8049 paf.effective_end_date and
8050 paf.location_id=hl1.location_id and
8051 paf.person_id=ppf.person_id and
8052 --decode(paf.employment_category,'PT',p_date_tmp_emp,l_year_end) between
8053 ppos.actual_termination_date between
8054 ppf.effective_start_date and
8055 ppf.effective_end_date and
8056 ppf.person_type_id = ppt.person_type_id and
8057 --upper(ltrim(rtrim(ppt.system_person_type)))='EX_EMP' and
8058 ppf.business_group_id=p_business_group_id and
8059 ppf.person_id=ppos.person_id and
8060 ppos.actual_termination_date is not null and
8061 ppos.actual_termination_date >= l_year_start and
8062 ppos.actual_termination_date <= l_year_end and
8063 (
8064 (
8065 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
8066 hsck.segment6 is not null and
8067 hsck.segment6 = v_naic_code
8068 )
8069 OR
8070 (
8071 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
8072 hsck.segment6 is null and
8073 hsck.segment1 in (select segment3
8074 from per_ca_ee_report_lines
8075 where request_id = p_request_id and
8076 context = 'FORM13' and
8077 segment1 = 'NAIC' and
8078 segment2 = v_naic_code)
8079 )
8080 ) and
8081 exists
8082 (
8083 select 'X'
8084 from per_pay_proposals_v2 pppv
8085 where
8086 pppv.assignment_id = paf.assignment_id and
8087 pppv.approved = 'Y' and
8088 pppv.change_date <= l_year_end
8089 )
8090 union all
8091 select
8092 paf.person_id count_total,
8093 hl.meaning meaning,
8094 ppf.sex sex,
8095 'FR' employment_category,
8096 hl1.region_1 region_1
8097 from
8098 hr_lookups hl,
8099 per_jobs pj,
8100 per_assignments_f paf,
8101 per_people_f ppf,
8102 per_person_types ppt,
8103 per_periods_of_service ppos,
8104 hr_locations hl1,
8105 hr_soft_coding_keyflex hsck
8106 where
8107 hl.lookup_type='EEOG' and
8108 upper(ltrim(rtrim(hl.lookup_code)))
8109 = upper(ltrim(rtrim(pj.job_information1))) and
8110 upper(ltrim(rtrim(pj.job_information_category))) = 'CA' and
8111 pj.job_id=paf.job_id and
8112 paf.primary_flag = 'Y' and
8113 --l_year_end between
8114 ppos.actual_termination_date between
8115 paf.effective_start_date and
8116 paf.effective_end_date and
8117 (paf.employment_category is null OR
8118 substr(paf.employment_category,1,2) in ('FR','PR','PT')) and
8119 paf.location_id=hl1.location_id and
8120 paf.person_id=ppf.person_id and
8121 --l_year_end between
8122 ppos.actual_termination_date between
8123 ppf.effective_start_date and
8124 ppf.effective_end_date and
8125 ppf.person_type_id = ppt.person_type_id and
8126 --upper(ltrim(rtrim(ppt.system_person_type)))='EX_EMP' and
8127 ppf.business_group_id=p_business_group_id and
8128 ppf.person_id=ppos.person_id and
8129 ppos.actual_termination_date is not null and
8130 ppos.actual_termination_date >= l_year_start and
8131 ppos.actual_termination_date <= l_year_end and
8132 (
8133 (
8134 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
8135 hsck.segment6 is not null and
8136 hsck.segment6 = v_naic_code
8137 )
8138 OR
8139 (
8143 from per_ca_ee_report_lines
8140 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
8141 hsck.segment6 is null and
8142 hsck.segment1 in (select segment3
8144 where request_id = p_request_id and
8145 context = 'FORM13' and
8146 segment1 = 'NAIC' and
8147 segment2 = v_naic_code)
8148 )
8149 ) and
8150 exists
8151 (
8152 select 'X'
8153 from per_pay_proposals_v2 pppv
8154 where
8155 pppv.assignment_id = paf.assignment_id and
8156 pppv.approved = 'Y' and
8157 pppv.change_date <= l_year_end
8158 )
8159 )
8160 group by region_1,meaning,employment_category,sex
8161 order by region_1,meaning,employment_category,sex;
8162
8163 v_count number(10);
8164 v_meaning hr_lookups.meaning%TYPE;
8165 v_employment_category per_assignments_f.employment_category%TYPE;
8166 v_sex per_people_f.sex%TYPE;
8167 v_region_1 hr_locations.region_1%TYPE;
8168 prev_meaning hr_lookups.meaning%TYPE := 'test';
8169 prev_employment_category per_assignments_f.employment_category%TYPE := '
8170 ';
8171 prev_naic_code hr_lookups.lookup_code%TYPE;
8172 prev_sex per_people_f.sex%TYPE := '';
8173 prev_region_1 hr_locations.region_1%TYPE;
8174
8175 cursor cur_hr_lookups is
8176 select
8177 meaning
8178 from
8179 hr_lookups
8180 where
8181 lookup_type='CA_PROVINCE' and
8182 lookup_code=v_region_1;
8183
8184 v_province_name hr_lookups.meaning%TYPE;
8185
8186 cursor cur_terminated(desig NUMBER) is
8187 select
8188 count(distinct person_id) count,
8189 meaning meaning,
8190 employment_category employment_category,
8191 sex sex,
8192 region_1 region_1
8193 from
8194 (
8195 select
8196 paf.person_id person_id,
8197 hl.meaning meaning,
8198 substr(paf.employment_category,1,2) employment_category,
8199 ppf.sex sex,
8200 hl1.region_1 region_1
8201 from
8202 hr_lookups hl,
8203 per_jobs pj,
8204 per_assignments_f paf,
8205 per_people_f ppf,
8206 per_person_types ppt,
8207 per_periods_of_service ppos ,
8208 hr_locations hl1,
8209 hr_soft_coding_keyflex hsck
8210 where
8211 upper(ltrim(rtrim(hl.lookup_type)))='EEOG' and
8212 upper(ltrim(rtrim(hl.lookup_code)))
8213 = upper(ltrim(ltrim(pj.job_information1))) and
8214 upper(ltrim(rtrim(pj.job_information_category))) = 'CA' and
8215 pj.job_id=paf.job_id and
8216 paf.primary_flag = 'Y' and
8217 --decode(paf.employment_category,'PT',p_date_tmp_emp,l_year_end) between
8218 ppos.actual_termination_date between
8219 paf.effective_start_date and
8220 paf.effective_end_date and
8221 paf.employment_category is not null and
8222 substr(paf.employment_category,1,2) in ('FR','PR','PT') and
8223 paf.location_id=hl1.location_id and
8224 paf.person_id=ppf.person_id and
8225 --decode(paf.employment_category,'PT',p_date_tmp_emp,l_year_end) between
8226 ppos.actual_termination_date between
8227 ppf.effective_start_date and
8228 ppf.effective_end_date and
8229 ppf.person_type_id = ppt.person_type_id and
8230 --UPPER(LTRIM(RTRIM(ppt.system_person_type)))='EX_EMP' and
8231 ppf.business_group_id=p_business_group_id and
8232 ppf.person_id=ppos.person_id and
8233 ppos.actual_termination_date is not null and
8234 ppos.actual_termination_date >= l_year_start and
8235 ppos.actual_termination_date <= l_year_end and
8236 decode(desig,1,per_information5,
8237 2,per_information6,
8238 3,per_information7)='Y' and
8239 (
8240 (
8241 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
8242 hsck.segment6 is not null and
8246 (
8243 hsck.segment6 = v_naic_code
8244 )
8245 OR
8247 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
8248 hsck.segment6 is null and
8249 hsck.segment1 in (select segment3
8250 from per_ca_ee_report_lines
8251 where request_id = p_request_id and
8252 context = 'FORM13' and
8253 segment1 = 'NAIC' and
8254 segment2 = v_naic_code)
8255 )
8256 ) and
8257 exists
8258 (
8259 select 'X'
8260 from per_pay_proposals_v2 pppv
8261 where
8262 pppv.assignment_id = paf.assignment_id and
8263 pppv.approved = 'Y' and
8264 pppv.change_date <= l_year_end
8265 )
8266 union all
8267 select
8268 paf.person_id person_id,
8269 hl.meaning meaning,
8270 'FR' employment_category,
8271 ppf.sex sex,
8272 hl1.region_1 region_1
8273 from
8274 hr_lookups hl,
8275 per_jobs pj,
8276 per_assignments_f paf,
8277 per_people_f ppf,
8278 per_person_types ppt,
8279 per_periods_of_service ppos ,
8280 hr_locations hl1,
8281 hr_soft_coding_keyflex hsck
8282 where
8283 upper(ltrim(rtrim(hl.lookup_type)))='EEOG' and
8284 upper(ltrim(rtrim(hl.lookup_code)))
8285 = upper(ltrim(ltrim(pj.job_information1))) and
8286 upper(ltrim(rtrim(pj.job_information_category))) = 'CA' and
8287 pj.job_id=paf.job_id and
8288 paf.primary_flag = 'Y' and
8289 --l_year_end between
8290 ppos.actual_termination_date between
8291 paf.effective_start_date and
8292 paf.effective_end_date and
8293 (paf.employment_category is null OR
8294 substr(paf.employment_category,1,2) in ('FR','PR','PT')) and
8295 paf.location_id=hl1.location_id and
8296 paf.person_id=ppf.person_id and
8297 --l_year_end between
8298 ppos.actual_termination_date between
8299 ppf.effective_start_date and
8300 ppf.effective_end_date and
8301 ppf.person_type_id = ppt.person_type_id and
8302 --UPPER(LTRIM(RTRIM(ppt.system_person_type)))='EX_EMP' and
8303 ppf.business_group_id=p_business_group_id and
8304 ppf.person_id=ppos.person_id and
8305 ppos.actual_termination_date is not null and
8306 ppos.actual_termination_date >= l_year_start and
8307 ppos.actual_termination_date <= l_year_end and
8308 decode(desig,1,per_information5,
8309 2,per_information6,
8310 3,per_information7)='Y' and
8311 (
8312 (
8313 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
8314 hsck.segment6 is not null and
8315 hsck.segment6 = v_naic_code
8316 )
8317 OR
8318 (
8319 hsck.soft_coding_keyflex_id=paf.soft_coding_keyflex_id and
8320 hsck.segment6 is null and
8321 hsck.segment1 in (select segment3
8322 from per_ca_ee_report_lines
8323 where request_id = p_request_id and
8324 context = 'FORM13' and
8325 segment1 = 'NAIC' and
8326 segment2 = v_naic_code)
8327 )
8328 ) and
8329 exists
8330 (
8331 select 'X'
8332 from per_pay_proposals_v2 pppv
8333 where
8334 pppv.assignment_id = paf.assignment_id and
8335 pppv.approved = 'Y' and
8336 pppv.change_date <= l_year_end
8337 )
8338 )
8339 group by region_1,meaning,employment_category,sex
8340 order by region_1,meaning,employment_category,sex;
8341
8342 cursor cur_eeog is
8343 select
8344 meaning
8345 from
8346 hr_lookups
8347 where
8348 lookup_type='EEOG';
8349
8350 cursor cur_notfound(p_emp_cat number) is
8351 select
8352 segment2,
8353 v_meaning,
8354 decode(p_emp_cat,1,'FR',2,'PR',3,'PT') emp_category
8355 from
8356 per_ca_ee_report_lines where
8357 request_id=p_request_id and
8358 context='FORM14' and
8359 segment1='PROVINCE' and
8360 segment3 <> '0'
8361 minus
8362 select
8363 segment2,
8364 segment3,
8365 segment4
8366 from
8367 per_ca_ee_report_lines
8368 where
8369 request_id=p_request_id and
8370 context='FORM6' and
8371 segment1='PROVINCE'and
8372 segment21 = v_naic_code;
8373
8374 cursor cur_count_national is
8375 select
8376 segment3,
8377 segment4,
8378 sum(to_number(segment5)) segment5,
8379 sum(to_number(segment6)) segment6,
8380 sum(to_number(segment7)) segment7,
8381 sum(to_number(segment8)) segment8,
8382 sum(to_number(segment9)) segment9,
8383 sum(to_number(segment10)) segment10,
8384 sum(to_number(segment11)) segment11,
8385 sum(to_number(segment12)) segment12,
8386 sum(to_number(segment13)) segment13,
8387 sum(to_number(segment14)) segment14,
8388 sum(to_number(segment15)) segment15,
8389 sum(to_number(segment16)) segment16
8390 from
8391 per_ca_ee_report_lines
8392 where
8393 request_id = p_request_id and
8394 context = 'FORM6' and
8395 segment1 = 'PROVINCE' and
8396 segment21 = v_naic_code
8397 group by segment3,segment4;
8398
8399 begin
8400
8401 hr_utility.trace('Form6 starts Here !!!!!!');
8402
8406
8403 for naic in cur_naic loop
8404
8405 v_naic_code := naic.naic_code;
8407 hr_utility.trace('Form6: v_naic = ' || v_naic_code );
8408
8409 for j in cur_terminated_total
8410 loop
8411
8412 v_count := j.count_total;
8413 v_meaning := j.meaning;
8414 v_employment_category := j.employment_category;
8415 v_sex := j.sex;
8416 v_region_1 := j.region_1;
8417
8418 open cur_hr_lookups;
8419 fetch cur_hr_lookups into v_province_name;
8420 close cur_hr_lookups;
8421
8422 if ((prev_region_1 <> v_region_1) or
8423 (ltrim(rtrim(prev_meaning)) <> ltrim(rtrim(v_meaning))) or
8424 (ltrim(rtrim(prev_naic_code)) <> ltrim(rtrim(v_naic_code))) or
8425 (ltrim(rtrim(prev_employment_category)) <>
8426 ltrim(rtrim(v_employment_category)))) then
8427
8428 per_ca_ee_extract_pkg.k := per_ca_ee_extract_pkg.k + 1;
8429
8430 insert into per_ca_ee_report_lines
8431 (request_id,
8432 line_number,
8433 context,
8434 segment1,
8435 segment2,
8436 segment3,
8437 segment4,
8438 segment5,
8439 segment6,
8440 segment7,
8441 segment8,
8442 segment9,
8443 segment10,
8444 segment11,
8445 segment12,
8446 segment13,
8447 segment14,
8448 segment15,
8449 segment16,
8450 segment21
8451 ) values
8452 (p_request_id,
8453 k,
8454 'FORM6',
8455 'PROVINCE',
8456 v_province_name,
8457 v_meaning,
8458 v_employment_category,
8459 nvl(v_count,0),
8460 decode(v_sex,'F',v_count,0),
8461 decode(v_sex,'M',v_count,0),
8462 '0',
8463 '0',
8464 '0',
8465 '0',
8466 '0',
8467 '0',
8468 '0',
8469 '0',
8470 '0',
8471 v_naic_code
8472 );
8473
8474 else
8475
8476 if prev_region_1 = v_region_1 and
8477 prev_meaning = v_meaning and
8478 prev_naic_code = v_naic_code and
8479 prev_employment_category = v_employment_category and
8480 prev_sex <> v_sex then
8481
8482 if v_sex = 'M' then
8483
8484 update per_ca_ee_report_lines set
8485 segment7=nvl(v_count,0),
8486 segment5=segment5 + nvl(v_count,0)
8487 where request_id=p_request_id and
8488 line_number = per_ca_ee_extract_pkg.k and
8489 context='FORM5' and
8490 segment1='PROVINCE' and
8491 segment2=v_province_name and
8492 segment3=v_meaning and
8493 segment4=v_employment_category and
8494 segment21=v_naic_code;
8495
8496 elsif v_sex = 'F' then
8497
8498 update per_ca_ee_report_lines set
8499 segment6=nvl(v_count,0),
8500 segment5=segment5 + nvl(v_count,0)
8501 where request_id=p_request_id and
8502 line_number = per_ca_ee_extract_pkg.k and
8503 context='FORM5' and
8504 segment1='PROVINCE' and
8505 segment2=v_province_name and
8506 segment3=v_meaning and
8507 segment4=v_employment_category and
8508 segment21=v_naic_code;
8509
8510 end if;
8511
8512 end if;
8513
8514 end if;
8515
8516 prev_meaning := v_meaning;
8517 prev_employment_category := v_employment_category;
8518 prev_sex := v_sex;
8519 prev_region_1 := v_region_1;
8520 prev_naic_code := v_naic_code;
8521
8522 end loop; -- End loop cur_terminated_total
8523
8524 for i in 1..3 loop
8525
8526 for j in cur_terminated(i)
8527 loop
8528
8529 v_sex := j.sex;
8530 v_employment_category := j.employment_category;
8531 v_meaning := j.meaning;
8532 v_count := j.count;
8533 v_region_1 := j.region_1;
8534
8535 open cur_hr_lookups;
8536 fetch cur_hr_lookups into v_province_name;
8537 close cur_hr_lookups;
8538
8539 if i = 1 then
8540
8541 if v_sex = 'M' then
8542
8543 update per_ca_ee_report_lines set
8544 segment8 = nvl(segment8,0) + nvl(v_count,0),
8545 segment9 = 0,
8546 segment10 = nvl(v_count,0)
8547 where
8548 request_id = p_request_id and
8549 context = 'FORM6' and
8550 segment1 = 'PROVINCE' and
8551 segment2 = v_province_name and
8552 segment3 = v_meaning and
8553 segment3 = v_employment_category and
8554 segment21 = v_naic_code;
8555
8556 elsif v_sex = 'F' then
8557
8558 update per_ca_ee_report_lines set
8559 segment8 = nvl(segment8,0) + nvl(v_count,0),
8560 segment9 = nvl(v_count,0),
8561 segment10 = 0
8562 where
8563 request_id = p_request_id and
8564 context='FORM6' and
8565 segment1 = 'PROVINCE' and
8569 segment21 = v_naic_code;
8566 segment2 = v_province_name and
8567 segment3 = v_meaning and
8568 segment3 = v_employment_category and
8570
8571 end if;
8572
8573 elsif i = 2 then
8574
8575 if v_sex = 'M' then
8576
8577 update per_ca_ee_report_lines set
8578 segment11 = nvl(segment11,0) + nvl(v_count,0),
8579 segment12 = 0,
8580 segment13 = nvl(v_count,0)
8581 where
8582 request_id = p_request_id and
8583 context='FORM6' and
8584 segment1 = 'PROVINCE' and
8585 segment2 = v_province_name and
8586 segment3 = v_meaning and
8587 segment3 = v_employment_category and
8588 segment21 = v_naic_code;
8589
8590 elsif v_sex = 'F' then
8591
8592 update per_ca_ee_report_lines set
8593 segment11 = nvl(segment11,0) + nvl(v_count,0),
8594 segment12 = nvl(v_count,0),
8595 segment13 = 0
8596 where
8597 request_id = p_request_id and
8598 context='FORM6' and
8599 segment1 = 'PROVINCE' and
8600 segment2 = v_province_name and
8601 segment3 = v_meaning and
8602 segment3 = v_employment_category and
8603 segment21 = v_naic_code;
8604
8605 end if;
8606
8607 elsif i = 3 then
8608
8609 if v_sex = 'M' then
8610
8611 update per_ca_ee_report_lines set
8612 segment14 = nvl(segment14,0) + nvl(v_count,0),
8613 segment15 = 0,
8614 segment16 = nvl(v_count,0)
8615 where
8616 request_id = p_request_id and
8617 context='FORM6' and
8618 segment1 = 'PROVINCE' and
8619 segment2 = v_province_name and
8620 segment3 = v_meaning and
8621 segment3 = v_employment_category and
8622 segment21 = v_naic_code;
8623
8624 elsif v_sex = 'F' then
8625
8626 update per_ca_ee_report_lines set
8627 segment14 = nvl(segment14,0) + nvl(v_count,0),
8628 segment15 = nvl(v_count,0),
8629 segment16 = 0
8630 where
8631 request_id = p_request_id and
8632 context='FORM6' and
8633 segment1 = 'PROVINCE' and
8634 segment2 = v_province_name and
8635 segment3 = v_meaning and
8636 segment3 = v_employment_category and
8637 segment21 = v_naic_code;
8638
8639 end if;
8640 end if;
8641
8642 end loop; -- End loop cur_terminated
8643
8644 end loop; -- End loop Designated Group
8645
8646
8647 for i in cur_eeog loop
8648
8649 v_meaning := i.meaning;
8650
8651 hr_utility.trace('Form6: cur_eeog: v_eeog' || v_meaning);
8652
8653 for emp_cat in 1..3 loop
8654
8655 for x in cur_notfound(emp_cat) loop
8656
8657 hr_utility.trace('Form6: cur_notfound' );
8658
8659 per_ca_ee_extract_pkg.k := per_ca_ee_extract_pkg.k + 1;
8660
8661 insert into per_ca_ee_report_lines
8662 (request_id,
8663 line_number,
8664 context,
8665 segment1,
8666 segment2,
8667 segment3,
8668 segment4,
8669 segment5,
8670 segment6,
8671 segment7,
8672 segment8,
8673 segment9,
8674 segment10,
8675 segment11,
8676 segment12,
8677 segment13,
8678 segment14,
8679 segment15,
8680 segment16,
8681 segment21) values
8682 ( p_request_id,
8683 per_ca_ee_extract_pkg.k,
8684 'FORM6',
8685 'PROVINCE',
8686 x.segment2,
8687 v_meaning,
8688 x.emp_category,
8689 0,
8690 0,
8691 0,
8692 0,
8693 0,
8694 0,
8695 0,
8696 0,
8697 0,
8698 0,
8699 0,
8700 0,
8701 v_naic_code);
8702
8703 end loop; -- End loop cur_notfound
8704
8705 end loop; -- End loop emp_cat
8706
8707 end loop; -- End loop cur_eeog
8708
8709 for count_national in cur_count_national loop
8710
8711 hr_utility.trace('Form6: cur_count_national. ');
8712
8713 insert into per_ca_ee_report_lines
8714 (request_id,
8715 line_number,
8716 context,
8717 segment1,
8718 segment2,
8719 segment3,
8720 segment4,
8721 segment5,
8722 segment6,
8723 segment7,
8724 segment8,
8725 segment9,
8726 segment10,
8727 segment11,
8728 segment12,
8729 segment13,
8730 segment14,
8731 segment15,
8732 segment21) values
8733 ( p_request_id,
8734 per_ca_ee_extract_pkg.k,
8735 'FORM6',
8736 'NATIONAL',
8737 count_national.segment3,
8738 count_national.segment4,
8742 count_national.segment8,
8739 count_national.segment5,
8740 count_national.segment6,
8741 count_national.segment7,
8743 count_national.segment9,
8744 count_national.segment10,
8745 count_national.segment11,
8746 count_national.segment12,
8747 count_national.segment13,
8748 count_national.segment14,
8749 count_national.segment15,
8750 count_national.segment16,
8751 v_naic_code);
8752
8753 end loop; -- End loop cur_count_total
8754
8755 prev_naic_code := v_naic_code;
8756
8757 end loop; --End loop of cur_naic
8758
8759 return 1;
8760
8761 end;
8762 end form6;
8763
8764
8765 function update_rec(p_request_id number) return number is
8766
8767 begin
8768
8769 declare
8770
8771 cursor cur_temp_count is select
8772 segment13,
8773 segment14,
8774 segment15
8775 from
8776 per_ca_ee_report_lines
8777 where
8778 request_id=p_request_id and
8779 context='FORM11';
8780
8781 v_tot_fr number;
8782 v_tot_pr number;
8783 v_tot_pt number;
8784
8785 cursor cur_max_naic is
8786 select
8787 segment4 max_naic_code,
8788 max(to_number(segment3))
8789 from
8790 per_ca_ee_report_lines
8791 where
8792 request_id = p_request_id and
8793 context = 'FORM12' and
8794 segment1 = 'NAIC'
8795 group by segment4;
8796
8797 v_max_naic_code hr_lookups.lookup_code%TYPE;
8798 v_max_naic_count number;
8799
8800 cursor cur_less_than_max_naic is
8801 select
8802 segment4 naic_code
8803 from
8804 per_ca_ee_report_lines
8805 where request_id = p_request_id
8806 and to_number(segment3) < (select to_number(lookup_code)
8807 from pay_ca_legislation_info
8808 where lookup_type = 'EER1')
8809 and context = 'FORM12' and
8810 segment4 <> v_max_naic_code;
8811
8812 v_not_max_naic hr_lookups.lookup_code%TYPE;
8813
8814 cursor cur_not_max_naic_data is
8815 select
8816 context,
8817 segment1,
8818 segment2,
8819 segment3,
8820 segment4,
8821 segment5,
8822 segment6,
8823 segment7,
8824 segment8,
8825 segment9,
8826 segment10,
8827 segment11,
8828 segment12,
8829 segment13,
8830 segment14,
8831 segment15,
8832 segment16,
8833 segment17,
8834 segment18,
8835 segment19,
8836 segment20
8837 segment21
8838 from per_ca_ee_report_lines
8839 where
8840 request_id = p_request_id and
8841 context in ('FORM3','FORM4','FORM5','FORM6') and
8842 segment1 = 'NATIONAL' and
8843 segment21 = v_not_max_naic;
8844
8845 begin
8846
8847 hr_utility.trace('Function update_rec starts here !!!!');
8848
8849 open cur_temp_count;
8850 fetch cur_temp_count
8851 into v_tot_fr,
8852 v_tot_pr,
8853 v_tot_pt;
8854 close cur_temp_count;
8855
8856 if (nvl(v_tot_fr,0) + nvl(v_tot_pr,0) + nvl(v_tot_pt,0)) <= 0 then
8857 return -1;
8858 else
8859
8860 if
8861 ( ((nvl(v_tot_pt,0)/(nvl(v_tot_fr,0) + nvl(v_tot_pr,0) + nvl(v_tot_pt,0))) * 100) >= 20 ) then
8862
8863 update per_ca_ee_report_lines set
8864 segment20 = 'Y'
8865 WHERE
8866 request_id=p_request_id and
8867 context in ('FORM2','FORM3','FORM4','FORM5','FORM6');
8868 else
8869
8870 update per_ca_ee_report_lines set
8871 segment20 = decode(segment3,'PT','N','Y')
8872 WHERE
8873 request_id=p_request_id and
8874 context in ('FORM2','FORM3','FORM4','FORM5','FORM6') and
8875 segment1 = 'NATIONAL';
8876
8877 update per_ca_ee_report_lines set
8878 segment20 = decode(segment4,'PT','N','Y')
8879 WHERE
8880 request_id=p_request_id and
8881 context in ('FORM2','FORM3','FORM4','FORM5','FORM6') and
8882 segment1 in ('CMA','PROVINCE');
8883
8884 end if;
8885
8886 ------------------------------------------------------------
8887 -- update the NAIC record which has more than 1000 people --
8888 -- or max number of people with other NAIC. --
8889 ------------------------------------------------------------
8890
8891 open cur_max_naic;
8892 fetch cur_max_naic
8893 into v_max_naic_code,
8894 v_max_naic_count;
8895 close cur_max_naic;
8896
8897 hr_utility.trace('UPDATE_REC: v_max_naic_code: ' || v_max_naic_code);
8898
8899 for naic in cur_less_than_max_naic loop
8900
8901 v_not_max_naic := naic.naic_code;
8902
8903 hr_utility.trace('UPDATE_REC: v_not_max_naic: ' || v_not_max_naic);
8904
8905 for i in cur_not_max_naic_data loop
8906
8907 hr_utility.trace('UPDATE_REC: Form3 - 6' );
8908
8909 update per_ca_ee_report_lines
8910 set
8911 segment4 = segment4 + i.segment4,
8912 segment5 = segment5 + i.segment5,
8913 segment6 = segment6 + i.segment6,
8914 segment7 = segment7 + i.segment7,
8915 segment8 = segment8 + i.segment8,
8916 segment9 = segment9 + i.segment9,
8917 segment10 = segment10 + i.segment10,
8918 segment11 = segment11 + i.segment11,
8919 segment12 = segment12 + i.segment12,
8920 segment13 = segment13 + i.segment13,
8924 request_id = p_request_id and
8921 segment14 = segment14 + i.segment14,
8922 segment15 = segment15 + i.segment15
8923 where
8925 context = i.context and
8926 segment1 = i.segment1 and
8927 segment2 = i.segment2 and
8928 segment3 = i.segment3 and
8929 segment21 = v_max_naic_code;
8930
8931 hr_utility.trace('UPDATE_REC: Form3 - 6 End' );
8932
8933 end loop; -- End loop cur_not_max_naic_data
8934
8935 delete from per_ca_ee_report_lines
8936 where request_id = p_request_id and
8937 segment21 = v_not_max_naic;
8938 end loop;
8939
8940 commit;
8941 return 1;
8942
8943 end if;
8944
8945 end;
8946
8947 end update_rec;
8948
8949 end per_ca_ee_extract_pkg;