DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_RCT_INS

Source


1 Package Body pqh_rct_ins as
2 /* $Header: pqrctrhi.pkb 115.24 2004/02/19 13:29:18 srajakum noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  pqh_rct_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 insert the row into the schema.
21 --   3) To trap any constraint violations that may have occurred.
22 --   4) To raise any other errors.
23 --
24 -- Prerequisites:
25 --   This is an internal private procedure which must be called from the ins
26 --   procedure and must have all mandatory attributes set (except the
27 --   object_version_number which is initialised within this procedure).
28 --
29 -- In Parameters:
30 --   A Pl/Sql record structre.
31 --
32 -- Post Success:
33 --   The specified row will be inserted into the schema.
34 --
35 -- Post Failure:
36 --   If a check, unique or parent integrity constraint violation is raised the
37 --   constraint_error procedure will be called.
38 --
39 -- Developer Implementation Notes:
40 --   None.
41 --
42 -- Access Status:
43 --   Internal Row Handler Use Only.
44 --
45 -- {End Of Comments}
46 -- ----------------------------------------------------------------------------
47 Procedure insert_dml(p_rec in out nocopy pqh_rct_shd.g_rec_type) is
48 --
49   l_proc  varchar2(72) := g_package||'insert_dml';
50 --
51 Begin
52   hr_utility.set_location('Entering:'||l_proc, 5);
53   p_rec.object_version_number := 1;  -- Initialise the object version
54   --
55   --
56   -- Insert the row into: pqh_routing_categories
57   --
58   insert into pqh_routing_categories
59   (	routing_category_id,
60 	transaction_category_id,
61         enable_flag,
62         default_flag,
63         delete_flag,
64 	routing_list_id,
65 	position_structure_id,
66 	override_position_id,
67 	override_assignment_id,
68 	override_role_id,
69         override_user_id,
70 	object_version_number
71   )
72   Values
73   (	p_rec.routing_category_id,
74 	p_rec.transaction_category_id,
75         p_rec.enable_flag,
76         p_rec.default_flag,
77         p_rec.delete_flag,
78 	p_rec.routing_list_id,
79 	p_rec.position_structure_id,
80 	p_rec.override_position_id,
81 	p_rec.override_assignment_id,
82 	p_rec.override_role_id,
83         p_rec.override_user_id,
84 	p_rec.object_version_number
85   );
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     pqh_rct_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     pqh_rct_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     pqh_rct_shd.constraint_error
101       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
102   When Others Then
103     Raise;
104 End insert_dml;
105 --
109 -- {Start Of Comments}
106 -- ----------------------------------------------------------------------------
107 -- |------------------------------< pre_insert >------------------------------|
108 -- ----------------------------------------------------------------------------
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 pqh_rct_shd.g_rec_type) is
144 --
145   l_proc  varchar2(72) := g_package||'pre_insert';
146 --
147 --
148   Cursor C_Sel1 is select pqh_routing_categories_s.nextval from sys.dual;
149 --
150 --
151 Begin
152   hr_utility.set_location('Entering:'||l_proc, 5);
153   --
154   --
155   -- Select the next sequence number
156   --
157   Open C_Sel1;
158   Fetch C_Sel1 Into p_rec.routing_category_id;
159   Close C_Sel1;
160   --
161   --
162   hr_utility.set_location(' Leaving:'||l_proc, 10);
163 End pre_insert;
164 --
165 -- ----------------------------------------------------------------------------
166 -- |-----------------------------< post_insert >------------------------------|
167 -- ----------------------------------------------------------------------------
168 -- {Start Of Comments}
169 --
170 -- Description:
171 --   This private procedure contains any processing which is required after the
172 --   insert dml.
173 --
174 -- Prerequisites:
175 --   This is an internal procedure which is called from the ins procedure.
176 --
177 -- In Parameters:
178 --   A Pl/Sql record structre.
179 --
180 -- Post Success:
181 --   Processing continues.
182 --
183 -- Post Failure:
184 --   If an error has occurred, an error message and exception will be raised
185 --   but not handled.
186 --
187 -- Developer Implementation Notes:
188 --   Any post-processing required after the insert dml is issued should be
189 --   coded within this procedure. It is important to note that any 3rd party
190 --   maintenance should be reviewed before placing in this procedure.
191 --
192 -- Access Status:
193 --   Internal Row Handler Use Only.
194 --
195 -- {End Of Comments}
196 -- ----------------------------------------------------------------------------
197 Procedure post_insert(p_effective_date in date,p_rec in pqh_rct_shd.g_rec_type) is
198 --
199   l_proc  varchar2(72) := g_package||'post_insert';
200 --
201 Begin
202   hr_utility.set_location('Entering:'||l_proc, 5);
203 --
204   --
205   -- Start of API User Hook for post_insert.
206   --
207   begin
208     --
209     pqh_rct_rki.after_insert
210       (
211   p_routing_category_id           =>p_rec.routing_category_id
212  ,p_transaction_category_id       =>p_rec.transaction_category_id
213  ,p_enable_flag                   =>p_rec.enable_flag
214  ,p_default_flag                  =>p_rec.default_flag
215  ,p_delete_flag                   =>p_rec.delete_flag
216  ,p_effective_date                =>p_effective_date
217  ,p_routing_list_id               =>p_rec.routing_list_id
218  ,p_position_structure_id         =>p_rec.position_structure_id
219  ,p_override_position_id          =>p_rec.override_position_id
220  ,p_override_assignment_id        =>p_rec.override_assignment_id
221  ,p_override_role_id              =>p_rec.override_role_id
222  ,p_override_user_id              =>p_rec.override_user_id
223  ,p_object_version_number         =>p_rec.object_version_number
224       );
225     --
226   exception
227     --
228     when hr_api.cannot_find_prog_unit then
229       --
230       hr_api.cannot_find_prog_unit_error
231         (p_module_name => 'pqh_routing_categories'
232         ,p_hook_type   => 'AI');
233       --
234   end;
235   --
236   -- End of API User Hook for post_insert.
237   --
238   --
239   hr_utility.set_location(' Leaving:'||l_proc, 10);
240 End post_insert;
241 --
242 -- ----------------------------------------------------------------------------
243 -- |---------------------------------< ins >----------------------------------|
244 -- ----------------------------------------------------------------------------
245 Procedure ins
246   (
247   p_effective_date in date,
248   p_rec        in out nocopy pqh_rct_shd.g_rec_type
249   ) is
250 --
251   l_proc  varchar2(72) := g_package||'ins';
255   --
252 --
253 Begin
254   hr_utility.set_location('Entering:'||l_proc, 5);
256   -- Call the supporting insert validate operations
257   --
258   pqh_rct_bus.insert_validate(p_rec,p_effective_date);
259   --
260   -- Call the supporting pre-insert operation
261   --
262   pre_insert(p_rec);
263   --
264   -- Insert the row
265   --
266   insert_dml(p_rec);
267   --
268   -- Call the supporting post-insert operation
269   --
270   post_insert(p_effective_date,p_rec);
271 end ins;
272 --
273 -- ----------------------------------------------------------------------------
274 -- |---------------------------------< ins >----------------------------------|
275 -- ----------------------------------------------------------------------------
276 Procedure ins
277   (
278   p_effective_date in date,
279   p_routing_category_id          out nocopy number,
280   p_transaction_category_id      in number,
281   p_enable_flag                  in varchar2       default 'Y',
282   p_default_flag                 in varchar2       default null,
283   p_delete_flag                 in varchar2       default null,
284   p_routing_list_id              in number         default null,
285   p_position_structure_id        in number         default null,
286   p_override_position_id         in number         default null,
287   p_override_assignment_id       in number         default null,
288   p_override_role_id           in number           default null,
289   p_override_user_id           in number           default null,
290   p_object_version_number        out nocopy number
291   ) is
292 --
293   l_rec	  pqh_rct_shd.g_rec_type;
294   l_proc  varchar2(72) := g_package||'ins';
295 --
296 Begin
297   hr_utility.set_location('Entering:'||l_proc, 5);
298   --
299   -- Call conversion function to turn arguments into the
300   -- p_rec structure.
301   --
302   l_rec :=
303   pqh_rct_shd.convert_args
304   (
305   null,
306   p_transaction_category_id,
307   p_enable_flag,
308   p_default_flag,
309   p_delete_flag,
310   p_routing_list_id,
311   p_position_structure_id,
312   p_override_position_id,
313   p_override_assignment_id,
314   p_override_role_id,
315   p_override_user_id,
316   null
317   );
318   --
319   -- Having converted the arguments into the pqh_rct_rec
320   -- plsql record structure we call the corresponding record business process.
321   --
322   ins(p_effective_date,l_rec);
323   --
324   -- As the primary key argument(s)
325   -- are specified as an OUT's we must set these values.
326   --
327   p_routing_category_id := l_rec.routing_category_id;
328   p_object_version_number := l_rec.object_version_number;
329   --
330   hr_utility.set_location(' Leaving:'||l_proc, 10);
331 End ins;
332 --
333 end pqh_rct_ins;