DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_TAT_INS

Source


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