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