DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_ELC_RESULT_API

Source


1 Package Body hr_elc_result_api as
2 /* $Header: peersapi.pkb 115.3 2002/12/11 10:29:50 pkakar noship $ */
3 --
4 -- Package Variables
5 --
6 g_package  varchar2(33) := '  hr_elc_result_api.';
7 --
8 -- ----------------------------------------------------------------------------
9 -- |--------------------------< create_election_result >--------------------------|
10 -- ----------------------------------------------------------------------------
11 --
12 procedure create_election_result
13   (p_validate                      in     boolean  default false
14   ,p_effective_date                in     date
15   ,p_job_id                        in     number
16   ,p_person_id                     in     number
17   ,p_start_date                    in     date
18   ,p_end_date                      in     date
19   ,p_primary_contact_flag          in     varchar2
20   ,p_election_candidate_id         in     number
21   ,p_ovn_election_candidates        in out nocopy number
22   ,p_business_group_id             in     number
23   ,p_election_id                   in     number
24   ,p_rank                          in     number
25   ,p_role_id                          out nocopy number
26   ,p_ovn_per_roles           out nocopy number
27   ) is
28 
29   --
30   -- Declare cursors and local variables
31   --
32 
33   l_proc                         varchar2(72) := g_package||'create_election_result';
34   l_job_group_id                 number;
35   l_role_id                      per_roles.role_id%TYPE;
36   l_ovn_election_candidates       per_election_candidates.object_version_number%TYPE;
37   l_temp_ovn per_election_candidates.object_version_number%TYPE := p_ovn_election_candidates;
38   l_ovn_per_roles       per_roles.object_version_number%TYPE;
39   l_effective_date           date;
40   l_start_date               date;
41   l_end_date                 date;
42 --
43 -- Cusor to get the job_group_id for the given job_id
44    cursor c_get_job_group_id is
45      select job_group_id
46      from per_jobs
47      where job_id = p_job_id;
48 ---
49 begin
50   hr_utility.set_location('Entering:'|| l_proc, 10);
51   --
52   -- Issue a savepoint
53   --
54   savepoint create_election_result;
55   --
56   -- Truncate the time portion from all IN date parameters
57   --
58      l_effective_date := trunc(p_effective_date);
59      l_start_date:= trunc(p_start_date);
60      l_end_date:= trunc(p_end_date);
61 
62   -- Get job_group_id for the passed in job_id
63   open c_get_job_group_id;
64   fetch c_get_job_group_id into l_job_group_id;
65   close c_get_job_group_id;
66   --
67   -- store ovn passed in
68   l_ovn_election_candidates := p_ovn_election_candidates;
69   -- Call per_supplementary_role_api to create the record in per_roles
70   per_supplementary_role_api.create_supplementary_role
71       (p_effective_date                => l_effective_date
72       ,p_job_group_id                  => l_job_group_id
73       ,p_job_id                        => p_job_id
74       ,p_person_id                     => p_person_id
75       ,p_start_date                    => l_start_date
76       ,p_end_date                      => l_end_date
77       ,p_primary_contact_flag          => p_primary_contact_flag
78       ,p_role_id                       => l_role_id
79       ,p_object_version_number        => l_ovn_per_roles);
80   --
81  --  Call the per_elc_candidate_api to insert the rank and
82  -- role for the candidate.
83 
84  hr_elc_candidate_api.update_election_candidate
85      (p_election_candidate_id         => p_election_candidate_id
86      ,p_object_version_number         => l_ovn_election_candidates
87      ,p_business_group_id             => p_business_group_id
88      ,p_person_id                     => p_person_id
89      ,p_election_id                   => p_election_id
90      ,p_rank                          => p_rank
91      ,p_role_id                       => l_role_id);
92 
93   -- When in validation only mode raise the Validate_Enabled exception
94   --
95   if p_validate then
96     raise hr_api.validate_enabled;
97   end if;
98   --
99 
100   -- Set all output arguments
101   --
102   p_role_id                     := l_role_id;
103   p_ovn_election_candidates      := l_ovn_election_candidates;
104   p_ovn_per_roles      := l_ovn_per_roles;
105   --
106   hr_utility.set_location(' Leaving:'||l_proc, 70);
107 exception
108   when hr_api.validate_enabled then
109     --
110     -- As the Validate_Enabled exception has been raised
111     -- we must rollback to the savepoint
112     --
113     rollback to create_election_result;
114     --
115     -- Only set output warning arguments
116     -- (Any key or derived arguments must be set to null
117     -- when validation only mode is being used.)
118     --
119    p_role_id                     := null;
120     p_ovn_per_roles      := null;
121 
122     hr_utility.set_location(' Leaving:'||l_proc, 80);
123   when others then
124     --
125     -- A validation or unexpected error has occured
126     --
127     rollback to create_election_result ;
128     --
129     -- set in out parameters and set out parameters
130     --
131     p_role_id                     := null;
132     p_ovn_per_roles      := null;
133     p_ovn_election_candidates     := l_temp_ovn;
134     hr_utility.set_location(' Leaving:'||l_proc, 90);
135     raise;
136 end create_election_result;
137 --
138 
139 -- ----------------------------------------------------------------------------
140 -- |--------------------------< update_election_result >--------------------------|
141 -- ----------------------------------------------------------------------------
142 --
143 procedure update_election_result
144   (p_validate                      in     boolean  default false
145   ,p_effective_date                in     date
146   ,p_role_id                       in     number
147   ,p_ovn_per_roles                 in out nocopy number
148   ,p_job_id                        in     number   default hr_api.g_number
149   ,p_person_id                     in     number   default hr_api.g_number
150   ,p_start_date                    in     date     default hr_api.g_date
151   ,p_end_date                      in     date     default hr_api.g_date
152   ,p_primary_contact_flag          in     varchar2 default hr_api.g_varchar2
153   ,p_election_candidate_id         in     number   default hr_api.g_number
154   ,p_business_group_id             in     number   default hr_api.g_number
155   ,p_election_id                   in     number   default hr_api.g_number
156   ,p_ovn_election_candidates       in out nocopy number
157   ,p_rank                          in     number   default hr_api.g_number
158   ) is
159 
160   --
161   -- Declare cursors and local variables
162   --
163 
164   l_proc                varchar2(72) := g_package||'update_election_result';
165   l_job_group_id        number;
166   l_ovn_election_candidates       per_election_candidates.object_version_number%TYPE;
167   l_ovn_per_roles       per_roles.object_version_number%TYPE;
168   l_effective_date           date;
169   l_start_date               date;
170   l_end_date                 date;
171 --
172 -- Cusor to get the job_group_id for the given job_id
173    cursor c_get_job_group_id is
174      select job_group_id
175      from per_jobs
176      where job_id = p_job_id;
177 ---
178 begin
179   hr_utility.set_location('Entering:'|| l_proc, 10);
180   --
181   -- Issue a savepoint
182   --
183   savepoint update_election_result;
184   --
185   -- Truncate the time portion from all IN date parameters
186   --
187      l_effective_date := trunc(p_effective_date);
188      l_start_date:= trunc(p_start_date);
189      l_end_date:= trunc(p_end_date);
190 
191   -- Get job_group_id for the passed in job_id
192   open c_get_job_group_id;
193   fetch c_get_job_group_id into l_job_group_id;
194   close c_get_job_group_id;
195   --
196   -- store ovn passed in
197   l_ovn_election_candidates    :=  p_ovn_election_candidates;
198   l_ovn_per_roles    :=  p_ovn_per_roles;
199 
200   -- Call per_supplementary_role_api to update the record in per_roles
201   per_supplementary_role_api.update_supplementary_role
202       (p_effective_date                => l_effective_date
203       ,p_role_id                       => p_role_id
204       ,p_object_version_number         => l_ovn_per_roles
205       ,p_start_date                    => l_start_date
206       ,p_end_date                      => l_end_date
207       ,p_primary_contact_flag          => p_primary_contact_flag);
208   --
209   --
210  --  Call the per_elc_candidate_api to insert the rank
211  --  and role fro the candidate.
212 
213  hr_elc_candidate_api.update_election_candidate
214      (p_election_candidate_id         => p_election_candidate_id
215      ,p_object_version_number        => l_ovn_election_candidates
216      ,p_business_group_id             => p_business_group_id
217      ,p_election_id                   => p_election_id
218      ,p_person_id                     => p_person_id
219      ,p_rank                          => p_rank
220      ,p_role_id                       => p_role_id);
221   -- Set all output arguments
222   --
223   p_ovn_election_candidates      := l_ovn_election_candidates;
224   p_ovn_per_roles      := l_ovn_per_roles;
225   --
226   hr_utility.set_location(' Leaving:'||l_proc, 70);
227 exception
228   when hr_api.validate_enabled then
229     --
230     -- As the Validate_Enabled exception has been raised
231     -- we must rollback to the savepoint
232     --
233     rollback to update_election_result;
234     --
235     -- Only set output warning arguments
236     -- (Any key or derived arguments must be set to null
237     -- when validation only mode is being used.)
238     --
239     p_ovn_election_candidates      := null;
240     p_ovn_per_roles      := null;
241 
242     hr_utility.set_location(' Leaving:'||l_proc, 80);
243   when others then
244     --
245     -- A validation or unexpected error has occured
246     --
247     rollback to create_election_result ;
248     --
249     -- set in out parameters and set out parameters
250     --
251      p_ovn_election_candidates      := null;
252     p_ovn_per_roles      := null;
253     --
254     hr_utility.set_location(' Leaving:'||l_proc, 90);
255     raise;
256 end update_election_result;
257 --
258 end hr_elc_result_api;