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