DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_CET_INS

Source


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