DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_TCA_INS

Source


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