DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_RECRUIT_ACTIVITY_FOR_PKG

Source


1 PACKAGE BODY PER_RECRUIT_ACTIVITY_FOR_PKG as
2 /* $Header: percf01t.pkb 115.1 2003/02/11 11:59:32 eumenyio ship $ */
3 --
4 /*  +=======================================================================+
5     |           Copyright (c) 1993 Oracle Corporation                       |
6     |              Redwood Shores, California, USA                          |
7     |                   All rights reserved.                                |
8     +=======================================================================+
9   Name
10     per_recruit_activity_for_pkg
11   Purpose
12     Supports the VACANCY block in the form PERWSDRA (Define Recruitment
13     Activity).
14   Notes
15 
16   History
17     21-Feb-94  H.Minton   40.0         Date created.
18     23-Nov-94  rfine      70.3         Suppressed index on business_group_id
19     29-Jan-95  D.Kerr	  70.5	       Removed WHO-columns for Set8 Changes.
20     29-Jan-95  D.Kerr	  70.6	       Added uniqueness checks to prevent
21 				       duplicate vacancies for a recruitment
22 				       activity  G1351
23     05-Mar-97  J.Alloun   70.7         Changed all occurances of system.dual
24                                        to sys.dual for next release requirements.
25 =============================================================================*/
26 -----------------------------------------------------------------------------
27 -- Name                                                                    --
28 --   chk_vacancy_unique
29 -- Purpose                                                                 --
30 --   Checks that the given vacancy has not already been used for
31 --   the given recruitment activity
32 -----------------------------------------------------------------------------
33 procedure chk_vacancy_unique ( p_vacancy_id               NUMBER,
34 		               p_recruitment_activity_id NUMBER ) is
35   CURSOR c1 is
36     SELECT 1
37     FROM   per_recruitment_activity_for
38     WHERE  recruitment_activity_id = p_recruitment_activity_id
39     AND    vacancy_id		   = p_vacancy_id ;
40 l_dummy number ;
41 --
42 begin
43    open c1 ;
44    fetch c1 into l_dummy ;
45    if c1%found then
46        close c1 ;
47        hr_utility.set_message(801,'HR_6120_RAC_VACACNY_EXISTS');
48        hr_utility.raise_error ;
49    end if;
50    close c1 ;
51 --
52 end chk_vacancy_unique ;
53 --
54 --
55 -----------------------------------------------------------------------------
56 -- Name                                                                    --
57 --   Check_References                                                      --
58 -- Purpose                                                                 --
59 --   checks that deletes cannot take place of a recruitment activity if    --
60 --   there are vacancies i.e recruitment_activities_for the recruitment-   --
61 --   activity exist.
62 -----------------------------------------------------------------------------
63 --
64 PROCEDURE check_References(P_recruitment_activity_id    NUMBER,
65                            P_Business_group_id          NUMBER) IS
66 --
67   CURSOR csr_rec_ac_for
68                        (
69                         P_recruitment_activity_id   NUMBER,
70                         P_Business_group_id         NUMBER
71                        ) IS
72     SELECT recf.recruitment_activity_id
73     FROM   per_recruitment_activity_for recf
74     WHERE  recf.recruitment_activity_id = P_recruitment_activity_id
75     AND    recf.business_group_id + 0       = P_Business_group_id;
76 --
77   v_dummy_id              number;
78 --
79 --
80 
81   BEGIN
82        OPEN csr_rec_ac_for(P_recruitment_activity_id,
83                            P_Business_group_id);
84        FETCH csr_rec_ac_for into v_dummy_id;
85          IF csr_rec_ac_for%found then
86          CLOSE csr_rec_ac_for;
87           hr_utility.set_message(800,'HR_6110_RAC_RECRUIT_DEL_CHILD');
88           hr_utility.raise_error;
89          ELSE
90           CLOSE csr_rec_ac_for;
91          END IF;
92 
93   END check_References;
94 --
95 -----------------------------------------------------------------------------
96 -- Name                                                                    --
97 --   Insert_Row                                                            --
98 -- Purpose                                                                 --
99 --   Table handler procedure. Supports the insert of a VACANCY via the   --
100 --   Define Recruitment Activity form.                                     --
101 -- Arguments                                                               --
102 --   See below.                                                            --
103 -- Notes                                                                   --
104 --                                                                         --
105  -----------------------------------------------------------------------------
106 --
107 
108 PROCEDURE Insert_Row(X_Rowid                        IN OUT NOCOPY VARCHAR2,
109                      X_Recruitment_Activity_For_Id         IN OUT NOCOPY NUMBER,
110                      X_Business_Group_Id                   NUMBER,
111                      X_Vacancy_Id                          NUMBER,
112                      X_Recruitment_Activity_Id             NUMBER)
113 IS
114    CURSOR C IS
115             SELECT rowid
116             FROM PER_RECRUITMENT_ACTIVITY_FOR
117             WHERE recruitment_activity_for_id = X_Recruitment_Activity_For_Id;
118 
119 
120     CURSOR C2 IS
121                SELECT per_recruitment_activity_for_s.nextval
122                FROM sys.dual;
123 
124 BEGIN
125    --
126    -- Check that the vacancy id has not already been used for this
127    -- recruitment activity
128    --
129    chk_vacancy_unique ( p_recruitment_activity_id => X_recruitment_activity_id,
130 			p_vacancy_id		  => X_vacancy_id ) ;
131    --
132    if (X_Recruitment_Activity_For_Id is NULL) then
133      OPEN C2;
134        FETCH C2 INTO X_Recruitment_Activity_For_Id;
135      CLOSE C2;
136    end if;
137   INSERT INTO PER_RECRUITMENT_ACTIVITY_FOR
138          (recruitment_activity_for_id,
139           business_group_id,
140           vacancy_id,
141           recruitment_activity_id)
142    VALUES (
143           X_Recruitment_Activity_For_Id,
144           X_Business_Group_Id,
145           X_Vacancy_Id,
146           X_Recruitment_Activity_Id );
147 --
148   OPEN C;
149   FETCH C INTO X_Rowid;
150   if (C%NOTFOUND) then
151     CLOSE C;
152     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
153     hr_utility.set_message_token('PROCEDURE',
154                                  'per_recruit_activity_for_pkg.insert_row');
155     hr_utility.set_message_token('STEP','1');
156     hr_utility.raise_error;
157   end if;
158   CLOSE C;
159 END Insert_Row;
160 --
161 -----------------------------------------------------------------------------
162 -- Name                                                                    --
163 --   Lock_Row                                                              --
164 -- Purpose                                                                 --
165 --   Table handler procedure that supports the insert , update and delete  --
166 --   of a vacancy by applying a lock on a vacancy in the Define            --
167 --   Recruitment Activity form.                                            --
168 -- Arguments                                                               --
169 -- Notes                                                                   --
170 --   None.                                                                 --
171 -----------------------------------------------------------------------------
172 --
173 PROCEDURE Lock_Row(X_Rowid                                 VARCHAR2,
174 
175                    X_Recruitment_Activity_For_Id           NUMBER,
176                    X_Business_Group_Id                     NUMBER,
177                    X_Vacancy_Id                            NUMBER,
178                    X_Recruitment_Activity_Id               NUMBER)
179 IS
180   CURSOR C IS
181       SELECT *
182       FROM   PER_RECRUITMENT_ACTIVITY_FOR
183       WHERE  rowid = X_Rowid
184       FOR UPDATE of Recruitment_Activity_For_Id NOWAIT;
185   Recinfo C%ROWTYPE;
186 
187 BEGIN
188   OPEN C;
189   FETCH C INTO Recinfo;
190   if (C%NOTFOUND) then
191     CLOSE C;
192     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
193     hr_utility.set_message_token('PROCEDURE',
194                                  'per_recruit_activity_for_pkg.lock_row');
195     hr_utility.set_message_token('STEP','1');
196     hr_utility.raise_error;
197   end if;
198   CLOSE C;
199   if (
200       (   (Recinfo.recruitment_activity_for_id = X_Recruitment_Activity_For_Id)
201        OR (    (Recinfo.recruitment_activity_for_id IS NULL)
202            AND (X_Recruitment_Activity_For_Id IS NULL)))
203   AND (   (Recinfo.business_group_id = X_Business_Group_Id)
204        OR (    (Recinfo.business_group_id IS NULL)
205            AND (X_Business_Group_Id IS NULL)))
206   AND (   (Recinfo.vacancy_id = X_Vacancy_Id)
207        OR (    (Recinfo.vacancy_id IS NULL)
208            AND (X_Vacancy_Id IS NULL)))
209  AND (   (Recinfo.recruitment_activity_id = X_Recruitment_Activity_Id)
210        OR (    (Recinfo.recruitment_activity_id IS NULL)
211            AND (X_Recruitment_Activity_Id IS NULL)))
212       ) then
213     return;
214   else
215     FND_MESSAGE.Set_Name('FND', 'FORM_RECORD_CHANGED');
216     APP_EXCEPTION.RAISE_EXCEPTION;
217   end if;
218 
219 END Lock_Row;
220 --
221 -----------------------------------------------------------------------------
222 -- Name                                                                    --
223 --   Update_Row                                                            --
224 -- Purpose                                                                 --
225 --   Table handler procedure that supports the update of a VACACNY via     --
229 -- Notes                                                                   --
226 --   Define Recruitment Activity form.                                     --
227 -- Arguments                                                               --
228 --   See below.                                                            --
230 --   None.                                                                 --
231 -----------------------------------------------------------------------------
232 --
233 PROCEDURE Update_Row(X_Rowid                               VARCHAR2,
234                      X_Recruitment_Activity_For_Id         NUMBER,
235                      X_Business_Group_Id                   NUMBER,
236                      X_Vacancy_Id                          NUMBER,
237                      X_Recruitment_Activity_Id             NUMBER)
238 IS
239 BEGIN
240    --
241    -- Check that the vacancy id has not already been used for this
242    -- recruitment activity
243    --
244    chk_vacancy_unique ( p_recruitment_activity_id => X_recruitment_activity_id,
245 			p_vacancy_id		  => X_vacancy_id ) ;
246    --
247   UPDATE PER_RECRUITMENT_ACTIVITY_FOR
248   SET
249 
250    recruitment_activity_for_id               =    X_Recruitment_Activity_For_Id,
251    business_group_id                         =    X_Business_Group_Id,
252    vacancy_id                                =    X_Vacancy_Id,
253    recruitment_activity_id                   =    X_Recruitment_Activity_Id
254   WHERE rowid = X_rowid;
255 
256   if (SQL%NOTFOUND) then
257     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
258     hr_utility.set_message_token('PROCEDURE',
259                                  'per_recruit_activity_for_pkg.update_row');
260     hr_utility.set_message_token('STEP','1');
261     hr_utility.raise_error;
262   end if;
263 
264 END Update_Row;
265 --
266 -----------------------------------------------------------------------------
267 -- Name                                                                    --
268 --   Delete_Row                                                            --
269 -- Purpose                                                                 --
270 --   Table handler procedure that supports the delete of a VACACNY via     --
271 --   the Define Recruitment Activity form.                                 --
272 -- Arguments                                                               --
273 --   See below.                                                            --
274 -- Notes                                                                   --
275 --                                                                         --
276 -----------------------------------------------------------------------------
277 --
278 PROCEDURE Delete_Row(X_Rowid VARCHAR2) IS
279 BEGIN
280   DELETE FROM PER_RECRUITMENT_ACTIVITY_FOR
281   WHERE  rowid = X_Rowid;
282 
283   if (SQL%NOTFOUND) then
284     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
285     hr_utility.set_message_token('PROCEDURE',
286                                  'per_recruit_activity_for_pkg.delete_row');
287     hr_utility.set_message_token('STEP','1');
288     hr_utility.raise_error;
289   end if;
290 END Delete_Row;
291 
292 END PER_RECRUIT_ACTIVITY_FOR_PKG;