DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_TCP_INS

Source


1 Package Body hr_tcp_ins as
2 /* $Header: hrtcprhi.pkb 120.1 2011/04/28 11:07:08 sidsaxen ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  hr_tcp_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
54   (p_rec in out nocopy hr_tcp_shd.g_rec_type
55   ) is
56 --
57   l_proc  varchar2(72) := g_package||'insert_dml';
58 --
59 Begin
60   hr_utility.set_location('Entering:'||l_proc, 5);
61   p_rec.object_version_number := 1;  -- Initialise the object version
62   --
63   --
64   --
65   -- Added the following code as a part of Zero Downtime Patching Project.
66   -- Code Starts Here.
67   --
68   PER_RIC_PKG.chk_integrity (
69     p_entity_name=>'HR_TEMPLATE_ITEM_CONTEXT_PAGES',
70       p_ref_entity_info=>
71         PER_RIC_PKG.ref_entity_tbl(
72           PER_RIC_PKG.ref_info_rec('HR_TEMPLATE_ITEM_CONTEXTS_B',
73             PER_RIC_PKG.column_info_tbl(
74               PER_RIC_PKG.col_info_rec('TEMPLATE_ITEM_CONTEXT_ID',NULL,p_rec.template_item_context_id,NULL))),
75           PER_RIC_PKG.ref_info_rec('HR_TEMPLATE_TAB_PAGES_B',
76             PER_RIC_PKG.column_info_tbl(
77               PER_RIC_PKG.col_info_rec('TEMPLATE_TAB_PAGE_ID',NULL,p_rec.template_tab_page_id,NULL)))),
78      p_ref_type=>'INS');
79   --
80   -- Code Ends Here
81   --
82   --
83   -- Insert the row into: hr_template_item_context_pages
84   --
85   insert into hr_template_item_context_pages
86       (template_item_context_page_id
87       ,object_version_number
88       ,template_item_context_id
89       ,template_tab_page_id
90       )
91   Values
92     (p_rec.template_item_context_page_id
93     ,p_rec.object_version_number
94     ,p_rec.template_item_context_id
95     ,p_rec.template_tab_page_id
96     );
97   --
98   --
99   --
100   hr_utility.set_location(' Leaving:'||l_proc, 10);
101 Exception
102   When hr_api.check_integrity_violated Then
103     -- A check constraint has been violated
104     --
105     hr_tcp_shd.constraint_error
106       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
107   When hr_api.parent_integrity_violated Then
108     -- Parent integrity has been violated
109     --
110     hr_tcp_shd.constraint_error
111       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
112   When hr_api.unique_integrity_violated Then
113     -- Unique integrity has been violated
114     --
115     hr_tcp_shd.constraint_error
116       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
117   When Others Then
118     --
119     Raise;
120 End insert_dml;
121 --
122 -- ----------------------------------------------------------------------------
123 -- |------------------------------< pre_insert >------------------------------|
124 -- ----------------------------------------------------------------------------
125 -- {Start Of Comments}
126 --
127 -- Description:
128 --   This private procedure contains any processing which is required before
129 --   the insert dml. Presently, if the entity has a corresponding primary
130 --   key which is maintained by an associating sequence, the primary key for
131 --   the entity will be populated with the next sequence value in
132 --   preparation for the insert dml.
133 --
134 -- Prerequisites:
135 --   This is an internal procedure which is called from the ins procedure.
136 --
137 -- In Parameters:
138 --   A Pl/Sql record structre.
139 --
140 -- Post Success:
141 --   Processing continues.
142 --
143 -- Post Failure:
144 --   If an error has occurred, an error message and exception will be raised
145 --   but not handled.
146 --
147 -- Developer Implementation Notes:
148 --   Any pre-processing required before the insert dml is issued should be
149 --   coded within this procedure. As stated above, a good example is the
150 --   generation of a primary key number via a corresponding sequence.
151 --   It is important to note that any 3rd party maintenance should be reviewed
152 --   before placing in this procedure.
153 --
154 -- Access Status:
155 --   Internal Row Handler Use Only.
156 --
157 -- {End Of Comments}
158 -- ----------------------------------------------------------------------------
159 Procedure pre_insert
160   (p_rec  in out nocopy hr_tcp_shd.g_rec_type
161   ) is
162 --
163   l_proc  varchar2(72) := g_package||'pre_insert';
164 --
165   Cursor C_Sel1 is select hr_tcp_s.nextval from sys.dual
166 ;
167 --
168 Begin
169   hr_utility.set_location('Entering:'||l_proc, 5);
170   --
171   --
172   -- Select the next sequence number
173   --
174   Open C_Sel1;
175   Fetch C_Sel1 Into p_rec.template_item_context_page_id;
176   Close C_Sel1;
177   --
178   hr_utility.set_location(' Leaving:'||l_proc, 10);
179 End pre_insert;
180 --
181 -- ----------------------------------------------------------------------------
182 -- |-----------------------------< post_insert >------------------------------|
183 -- ----------------------------------------------------------------------------
184 -- {Start Of Comments}
185 --
186 -- Description:
187 --   This private procedure contains any processing which is required after the
188 --   insert dml.
189 --
190 -- Prerequisites:
191 --   This is an internal procedure which is called from the ins procedure.
192 --
193 -- In Parameters:
194 --   A Pl/Sql record structre.
195 --
196 -- Post Success:
197 --   Processing continues.
198 --
199 -- Post Failure:
200 --   If an error has occurred, an error message and exception will be raised
201 --   but not handled.
202 --
203 -- Developer Implementation Notes:
204 --   Any post-processing required after the insert dml is issued should be
205 --   coded within this procedure. It is important to note that any 3rd party
206 --   maintenance should be reviewed before placing in this procedure.
207 --
208 -- Access Status:
209 --   Internal Row Handler Use Only.
210 --
211 -- {End Of Comments}
212 -- ----------------------------------------------------------------------------
213 Procedure post_insert
214   (p_rec                          in hr_tcp_shd.g_rec_type
215   ) is
216 --
217   l_proc  varchar2(72) := g_package||'post_insert';
218 --
219 Begin
220   hr_utility.set_location('Entering:'||l_proc, 5);
221   begin
222     --
223     hr_tcp_rki.after_insert
224       (p_template_item_context_page_i
225       => p_rec.template_item_context_page_id
226       ,p_object_version_number
227       => p_rec.object_version_number
228       ,p_template_item_context_id
229       => p_rec.template_item_context_id
230       ,p_template_tab_page_id
231       => p_rec.template_tab_page_id
232       );
233     --
234   exception
235     --
236     when hr_api.cannot_find_prog_unit then
237       --
238       hr_api.cannot_find_prog_unit_error
239         (p_module_name => 'HR_TEMPLATE_ITEM_CONTEXT_PAGES'
240         ,p_hook_type   => 'AI');
241       --
242   end;
243   --
244   hr_utility.set_location(' Leaving:'||l_proc, 10);
245 End post_insert;
246 --
247 -- ----------------------------------------------------------------------------
248 -- |---------------------------------< ins >----------------------------------|
249 -- ----------------------------------------------------------------------------
250 Procedure ins
251   (p_rec                          in out nocopy hr_tcp_shd.g_rec_type
252   ) is
253 --
254   l_proc  varchar2(72) := g_package||'ins';
255 --
256 Begin
257   hr_utility.set_location('Entering:'||l_proc, 5);
258   --
259   -- Call the supporting insert validate operations
260   --
261   hr_tcp_bus.insert_validate
262      (p_rec
263      );
264   --
265   -- Call the supporting pre-insert operation
266   --
267   hr_tcp_ins.pre_insert(p_rec);
268   --
269   -- Insert the row
270   --
271   hr_tcp_ins.insert_dml(p_rec);
272   --
273   -- Call the supporting post-insert operation
274   --
275   hr_tcp_ins.post_insert
276      (p_rec
277      );
278   --
279   hr_utility.set_location('Leaving:'||l_proc, 20);
280 end ins;
281 --
282 -- ----------------------------------------------------------------------------
283 -- |---------------------------------< ins >----------------------------------|
284 -- ----------------------------------------------------------------------------
285 Procedure ins
286   (p_template_item_context_id       in     number
287   ,p_template_tab_page_id           in     number
288   ,p_template_item_context_page_i      out nocopy number
289   ,p_object_version_number             out nocopy number
290   ) is
291 --
292   l_rec	  hr_tcp_shd.g_rec_type;
293   l_proc  varchar2(72) := g_package||'ins';
294 --
295 Begin
296   hr_utility.set_location('Entering:'||l_proc, 5);
297   --
298   -- Call conversion function to turn arguments into the
299   -- p_rec structure.
300   --
301   l_rec :=
302   hr_tcp_shd.convert_args
303     (null
304     ,null
305     ,p_template_item_context_id
306     ,p_template_tab_page_id
307     );
308   --
309   -- Having converted the arguments into the hr_tcp_rec
310   -- plsql record structure we call the corresponding record business process.
311   --
312   hr_tcp_ins.ins
313      (l_rec
314      );
315   --
316   -- As the primary key argument(s)
317   -- are specified as an OUT's we must set these values.
318   --
319   p_template_item_context_page_i := l_rec.template_item_context_page_id;
320   p_object_version_number := l_rec.object_version_number;
321   --
322   hr_utility.set_location(' Leaving:'||l_proc, 10);
323 End ins;
324 --
325 end hr_tcp_ins;