DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_RFT_INS

Source


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