DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_SAT_INS

Source


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