DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_ASP_INS

Source


1 Package Body per_asp_ins as
2 /* $Header: peasprhi.pkb 115.15 2002/12/02 14:20:06 apholt ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  per_asp_ins.';  -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |------------------------------< insert_dml >------------------------------|
12 -- ----------------------------------------------------------------------------
13 -- {Start Of Comments}
14 --
15 -- Description:
16 --   This procedure controls the actual dml insert logic. The processing of
17 --   this procedure are as follows:
18 --   1) Initialise the object_version_number to 1 if the object_version_number
19 --      is defined as an attribute for this entity.
20 --   2) To set and unset the g_api_dml status as required (as we are about to
21 --      perform dml).
22 --   3) To insert the row into the schema.
23 --   4) To trap any constraint violations that may have occurred.
24 --   5) To raise any other errors.
25 --
26 -- Prerequisites:
27 --   This is an internal private procedure which must be called from the ins
28 --   procedure and must have all mandatory attributes set (except the
29 --   object_version_number which is initialised within this procedure).
30 --
31 -- In Parameters:
32 --   A Pl/Sql record structre.
33 --
34 -- Post Success:
35 --   The specified row will be inserted into the schema.
36 --
37 -- Post Failure:
38 --   On the insert dml failure it is important to note that we always reset the
39 --   g_api_dml status to false.
40 --   If a check, unique or parent integrity constraint violation is raised the
41 --   constraint_error procedure will be called.
42 --   If any other error is reported, the error will be raised after the
43 --   g_api_dml status is reset.
44 --
45 -- Developer Implementation Notes:
46 --   None.
47 --
48 -- Access Status:
49 --   Internal Row Handler Use Only.
50 --
51 -- {End Of Comments}
52 -- ----------------------------------------------------------------------------
53 Procedure insert_dml(p_rec in out nocopy per_asp_shd.g_rec_type) is
54 --
55   l_proc  varchar2(72) := g_package||'insert_dml';
56 --
57 Begin
58   hr_utility.set_location('Entering:'||l_proc, 5);
59   p_rec.object_version_number := 1;  -- Initialise the object version
60   --
61   -- Insert the row into: per_sec_profile_assignments
62   --
63   insert into per_sec_profile_assignments
64   (	sec_profile_assignment_id,
65 	user_id,
66 	security_group_id,
67 	business_group_id,
68 	security_profile_id,
69 	responsibility_id,
70 	responsibility_application_id,
71 	start_date,
72 	end_date,
73 	object_version_number
74   )
75   Values
76   (	p_rec.sec_profile_assignment_id,
77 	p_rec.user_id,
78 	p_rec.security_group_id,
79 	p_rec.business_group_id,
80 	p_rec.security_profile_id,
81 	p_rec.responsibility_id,
82 	p_rec.responsibility_application_id,
83 	p_rec.start_date,
84 	p_rec.end_date,
85 	p_rec.object_version_number
86   );
87   --
88   hr_utility.set_location(' Leaving:'||l_proc, 10);
89 Exception
90   When hr_api.check_integrity_violated Then
91     -- A check constraint has been violated
92     per_asp_shd.constraint_error
93       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
94   When hr_api.parent_integrity_violated Then
95     -- Parent integrity has been violated
96     per_asp_shd.constraint_error
97       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
98   When hr_api.unique_integrity_violated Then
99     -- Unique integrity has been violated
100     per_asp_shd.constraint_error
101       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
102   When Others Then
103     Raise;
104 End insert_dml;
105 --
106 -- ----------------------------------------------------------------------------
107 -- |------------------------------< pre_insert >------------------------------|
108 -- ----------------------------------------------------------------------------
109 -- {Start Of Comments}
110 --
111 -- Description:
112 --   This private procedure contains any processing which is required before
113 --   the insert dml. Presently, if the entity has a corresponding primary
114 --   key which is maintained by an associating sequence, the primary key for
115 --   the entity will be populated with the next sequence value in
116 --   preparation for the insert dml.
117 --
118 -- Prerequisites:
119 --   This is an internal procedure which is called from the ins procedure.
120 --
121 -- In Parameters:
122 --   A Pl/Sql record structre.
123 --
124 -- Post Success:
125 --   Processing continues.
126 --
127 -- Post Failure:
128 --   If an error has occurred, an error message and exception will be raised
129 --   but not handled.
130 --
131 -- Developer Implementation Notes:
132 --   Any pre-processing required before the insert dml is issued should be
133 --   coded within this procedure. As stated above, a good example is the
134 --   generation of a primary key number via a corresponding sequence.
135 --   It is important to note that any 3rd party maintenance should be reviewed
136 --   before placing in this procedure.
137 --
138 -- Access Status:
139 --   Internal Row Handler Use Only.
140 --
141 -- {End Of Comments}
142 -- ----------------------------------------------------------------------------
143 Procedure pre_insert(p_rec  in out nocopy per_asp_shd.g_rec_type) is
144 --
145   l_proc  varchar2(72) := g_package||'pre_insert';
146 --
147   Cursor C_Sel1 is select per_sec_profile_assignments_s.nextval from sys.dual;
148 --
149 Begin
150   hr_utility.set_location('Entering:'||l_proc, 5);
151   --
152   --
153   -- Select the next sequence number
154   --
155   Open C_Sel1;
156   Fetch C_Sel1 Into p_rec.sec_profile_assignment_id;
157   Close C_Sel1;
158   --
159   hr_utility.set_location(' Leaving:'||l_proc, 10);
160 End pre_insert;
161 --
162 -- ----------------------------------------------------------------------------
163 -- |-----------------------------< post_insert >------------------------------|
164 -- ----------------------------------------------------------------------------
165 -- {Start Of Comments}
166 --
167 -- Description:
168 --   This private procedure contains any processing which is required after the
169 --   insert dml.
170 --
171 -- Prerequisites:
172 --   This is an internal procedure which is called from the ins procedure.
173 --
174 -- In Parameters:
178 --   Processing continues.
175 --   A Pl/Sql record structre.
176 --
177 -- Post Success:
179 --
180 -- Post Failure:
181 --   If an error has occurred, an error message and exception will be raised
182 --   but not handled.
183 --
184 -- Developer Implementation Notes:
185 --   Any post-processing required after the insert dml is issued should be
186 --   coded within this procedure. It is important to note that any 3rd party
187 --   maintenance should be reviewed before placing in this procedure.
188 --
189 -- Access Status:
190 --   Internal Row Handler Use Only.
191 --
192 -- {End Of Comments}
193 -- ----------------------------------------------------------------------------
194 Procedure post_insert(p_rec in per_asp_shd.g_rec_type) is
195 --
196   l_proc  varchar2(72) := g_package||'post_insert';
197 --
198 Begin
199   hr_utility.set_location('Entering:'||l_proc, 5);
200 --
201 
202   --
203   -- Synchronize the dates in fnd_user_resp_groups for the assignment we
204   -- have just inserted...
205   --
206   per_asp_bus.Synchronize_Assignment_Dates
207      (p_user_id => p_rec.user_id
208      ,p_responsibility_id => p_rec.responsibility_id
209      ,p_application_id => p_rec.responsibility_application_id
210      ,p_security_group_id => p_rec.security_group_id
211      ,p_business_group_id => p_rec.business_group_id
212      );
213 
214 /*
215   --
216   -- Start of API User Hook for post_insert.
217   --
218   begin
219     --
220     per_asp_rki.after_insert
221       (
222   p_sec_profile_assignment_id     =>p_rec.sec_profile_assignment_id
223  ,p_user_id                       =>p_rec.user_id
224  ,p_security_group_id             =>p_rec.security_group_id
225  ,p_security_profile_id           =>p_rec.security_profile_id
226  ,p_responsibility_id             =>p_rec.responsibility_id
227  ,p_responsibility_application_i =>p_rec.responsibility_application_id
228  ,p_start_date                    =>p_rec.start_date
229  ,p_end_date                      =>p_rec.end_date
230  ,p_object_version_number         =>p_rec.object_version_number
231       );
232     --
233   exception
234     --
235     when hr_api.cannot_find_prog_unit then
236       --
237       hr_api.cannot_find_prog_unit_error
238         (p_module_name => 'per_sec_profile_assignments'
239         ,p_hook_type   => 'AI');
240       --
241   end;
242   --
243   -- End of API User Hook for post_insert.
244   --
245 */
246   --
247   hr_utility.set_location(' Leaving:'||l_proc, 10);
248 End post_insert;
249 --
250 -- ----------------------------------------------------------------------------
251 -- |---------------------------------< ins >----------------------------------|
252 -- ----------------------------------------------------------------------------
253 Procedure ins
254   (
255   p_rec        in out nocopy per_asp_shd.g_rec_type
256   ) is
257 --
258   l_proc  varchar2(72) := g_package||'ins';
259 --
260 Begin
261   hr_utility.set_location('Entering:'||l_proc, 5);
262   --
263   -- Call the supporting insert validate operations
264   --
265   per_asp_bus.insert_validate(p_rec);
266   --
267   -- Call the supporting pre-insert operation
268   --
269   pre_insert(p_rec);
270   --
271   -- Insert the row
272   --
273   insert_dml(p_rec);
274   --
275   -- Call the supporting post-insert operation
276   --
277   post_insert(p_rec);
278 end ins;
279 --
280 -- ----------------------------------------------------------------------------
281 -- |---------------------------------< ins >----------------------------------|
282 -- ----------------------------------------------------------------------------
283 Procedure ins
284   (
285   p_sec_profile_assignment_id    out nocopy number,
286   p_user_id                      in number,
287   p_security_group_id            in number,
288   p_business_group_id            in number,
289   p_security_profile_id          in number,
290   p_responsibility_id            in number,
291   p_responsibility_application_i in number,
292   p_start_date                   in date,
293   p_end_date                     in date             default null,
294   p_object_version_number        out nocopy number
295   ) is
296 --
297   l_rec	  per_asp_shd.g_rec_type;
298   l_proc  varchar2(72) := g_package||'ins';
299 --
300 Begin
301   hr_utility.set_location('Entering:'||l_proc, 5);
302   --
303   -- Call conversion function to turn arguments into the
304   -- p_rec structure.
305   --
306   l_rec :=
307   per_asp_shd.convert_args
308   (
309   null,
310   p_user_id,
311   p_security_group_id,
312   p_business_group_id,
313   p_security_profile_id,
314   p_responsibility_id,
315   p_responsibility_application_i,
316   p_start_date,
317   p_end_date,
318   null
319   );
320   --
321   -- Having converted the arguments into the per_asp_rec
322   -- plsql record structure we call the corresponding record business process.
323   --
324   ins(l_rec);
325   --
326   -- As the primary key argument(s)
327   -- are specified as an OUT's we must set these values.
328   --
329   p_sec_profile_assignment_id := l_rec.sec_profile_assignment_id;
330   p_object_version_number := l_rec.object_version_number;
331   --
332   hr_utility.set_location(' Leaving:'||l_proc, 10);
333 End ins;
334 --
335 end per_asp_ins;