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