1 Package Body pqh_cep_ins as
2 /* $Header: pqceprhi.pkb 115.3 2002/12/05 19:31:20 rpasapul ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' pqh_cep_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 -- 3) To insert the row into the schema.
21 -- 4) To trap any constraint violations that may have occurred.
22 -- 5) 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_cep_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_prefs
56 --
57 insert into pqh_copy_entity_prefs
58 ( copy_entity_pref_id,
59 table_route_id,
60 copy_entity_txn_id,
61 select_flag,
62 object_version_number
63 )
64 Values
65 ( p_rec.copy_entity_pref_id,
66 p_rec.table_route_id,
67 p_rec.copy_entity_txn_id,
68 p_rec.select_flag,
69 p_rec.object_version_number
70 );
71 --
72 hr_utility.set_location(' Leaving:'||l_proc, 10);
73 Exception
74 When hr_api.check_integrity_violated Then
75 -- A check constraint has been violated
76 pqh_cep_shd.constraint_error
77 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
78 When hr_api.parent_integrity_violated Then
79 -- Parent integrity has been violated
80 pqh_cep_shd.constraint_error
81 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
82 When hr_api.unique_integrity_violated Then
83 -- Unique integrity has been violated
84 pqh_cep_shd.constraint_error
85 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
86 When Others Then
87 Raise;
88 End insert_dml;
89 --
90 -- ----------------------------------------------------------------------------
91 -- |------------------------------< pre_insert >------------------------------|
92 -- ----------------------------------------------------------------------------
93 -- {Start Of Comments}
94 --
95 -- Description:
96 -- This private procedure contains any processing which is required before
97 -- the insert dml. Presently, if the entity has a corresponding primary
98 -- key which is maintained by an associating sequence, the primary key for
99 -- the entity will be populated with the next sequence value in
100 -- preparation for the insert dml.
101 --
102 -- Prerequisites:
103 -- This is an internal procedure which is called from the ins procedure.
104 --
105 -- In Parameters:
106 -- A Pl/Sql record structre.
107 --
108 -- Post Success:
109 -- Processing continues.
110 --
111 -- Post Failure:
112 -- If an error has occurred, an error message and exception will be raised
113 -- but not handled.
114 --
115 -- Developer Implementation Notes:
116 -- Any pre-processing required before the insert dml is issued should be
117 -- coded within this procedure. As stated above, a good example is the
118 -- generation of a primary key number via a corresponding sequence.
119 -- It is important to note that any 3rd party maintenance should be reviewed
120 -- before placing in this procedure.
121 --
122 -- Access Status:
123 -- Internal Row Handler Use Only.
124 --
125 -- {End Of Comments}
126 -- ----------------------------------------------------------------------------
127 Procedure pre_insert(p_rec in out nocopy pqh_cep_shd.g_rec_type) is
128 --
129 l_proc varchar2(72) := g_package||'pre_insert';
130 --
131 --
132 Cursor C_Sel1 is select pqh_copy_entity_prefs_s.nextval from sys.dual;
133 --
134 Begin
135 hr_utility.set_location('Entering:'||l_proc, 5);
136 --
137 --
138 -- Select the next sequence number
139 --
140 Open C_Sel1;
141 Fetch C_Sel1 Into p_rec.copy_entity_pref_id;
142 Close C_Sel1;
143 --
144 hr_utility.set_location(' Leaving:'||l_proc, 10);
145 End pre_insert;
146 --
147 -- ----------------------------------------------------------------------------
148 -- |-----------------------------< post_insert >------------------------------|
149 -- ----------------------------------------------------------------------------
150 -- {Start Of Comments}
151 --
152 -- Description:
153 -- This private procedure contains any processing which is required after the
154 -- insert dml.
155 --
156 -- Prerequisites:
157 -- This is an internal procedure which is called from the ins procedure.
158 --
159 -- In Parameters:
160 -- A Pl/Sql record structre.
161 --
162 -- Post Success:
163 -- Processing continues.
164 --
165 -- Post Failure:
166 -- If an error has occurred, an error message and exception will be raised
167 -- but not handled.
168 --
169 -- Developer Implementation Notes:
170 -- Any post-processing required after the insert dml is issued should be
171 -- coded within this procedure. It is important to note that any 3rd party
172 -- maintenance should be reviewed before placing in this procedure.
173 --
174 -- Access Status:
175 -- Internal Row Handler Use Only.
176 --
177 -- {End Of Comments}
178 -- ----------------------------------------------------------------------------
179 Procedure post_insert(
180 p_effective_date in date,p_rec in pqh_cep_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_cep_rki.after_insert
193 (
194 p_copy_entity_pref_id =>p_rec.copy_entity_pref_id
195 ,p_table_route_id =>p_rec.table_route_id
196 ,p_copy_entity_txn_id =>p_rec.copy_entity_txn_id
197 ,p_select_flag =>p_rec.select_flag
198 ,p_object_version_number =>p_rec.object_version_number
199 ,p_effective_date =>p_effective_date
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_copy_entity_prefs'
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_cep_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_cep_bus.insert_validate(p_rec
235 ,p_effective_date);
236 --
237 -- Call the supporting pre-insert operation
238 --
239 pre_insert(p_rec);
240 --
241 -- Insert the row
242 --
243 insert_dml(p_rec);
244 --
245 -- Call the supporting post-insert operation
246 --
247 post_insert(
248 p_effective_date,p_rec);
249 end ins;
250 --
251 -- ----------------------------------------------------------------------------
252 -- |---------------------------------< ins >----------------------------------|
253 -- ----------------------------------------------------------------------------
254 Procedure ins
255 (
256 p_effective_date in date,
257 p_copy_entity_pref_id out nocopy number,
258 p_table_route_id in number,
259 p_copy_entity_txn_id in number,
260 p_select_flag in varchar2 default null,
261 p_object_version_number out nocopy number
262 ) is
263 --
264 l_rec pqh_cep_shd.g_rec_type;
265 l_proc varchar2(72) := g_package||'ins';
266 --
267 Begin
268 hr_utility.set_location('Entering:'||l_proc, 5);
269 --
270 -- Call conversion function to turn arguments into the
271 -- p_rec structure.
272 --
273 l_rec :=
274 pqh_cep_shd.convert_args
275 (
276 null,
277 p_table_route_id,
278 p_copy_entity_txn_id,
279 p_select_flag,
280 null
281 );
282 --
283 -- Having converted the arguments into the pqh_cep_rec
284 -- plsql record structure we call the corresponding record business process.
285 --
286 ins(
287 p_effective_date,l_rec);
288 --
289 -- As the primary key argument(s)
290 -- are specified as an OUT's we must set these values.
291 --
292 p_copy_entity_pref_id := l_rec.copy_entity_pref_id;
293 p_object_version_number := l_rec.object_version_number;
294 --
295 hr_utility.set_location(' Leaving:'||l_proc, 10);
296 End ins;
297 --
298 end pqh_cep_ins;