1 Package Body per_za_tra_ins as
2 /* $Header: pezatrin.pkb 115.1 2002/12/05 06:52:33 nsugavan noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' per_za_tra_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 set and unset the g_api_dml status as required (as we are about to
21 -- perform dml).
22 -- 3) To insert the row into the schema.
23 -- 4) To trap any constraint violations that may have occurred.
24 -- 5) To raise any other errors.
25 --
26 -- Pre Conditions:
27 -- This is an internal private procedure which must be called from the ins
28 -- procedure and must have all mandatory attributes set (except the
29 -- object_version_number which is initialised within this procedure).
30 --
31 -- In Parameters:
32 -- A Pl/Sql record structre.
33 --
34 -- Post Success:
35 -- The specified row will be inserted into the schema.
36 --
37 -- Post Failure:
38 -- On the insert dml failure it is important to note that we always reset the
39 -- g_api_dml status to false.
40 -- If a check, unique or parent integrity constraint violation is raised the
41 -- constraint_error procedure will be called.
42 -- If any other error is reported, the error will be raised after the
43 -- g_api_dml status is reset.
44 --
45 -- Developer Implementation Notes:
46 -- None.
47 --
48 -- Access Status:
49 -- Internal Table Handler Use Only.
50 --
51 -- {End Of Comments}
52 -- ----------------------------------------------------------------------------
53 Procedure insert_dml(p_rec in out nocopy per_za_tra_shd.g_za_rec_type) is
54 --
55 l_proc varchar2(72) := g_package||'insert_dml';
56 --
57 Begin
58 hr_utility.set_location('Entering:'||l_proc, 5);
59
60 --
61 per_za_tra_shd.g_api_dml := true; -- Set the api dml status
62 --
63 -- Insert the row into: per_za_training
64 --
65 insert into per_za_training (
66 TRAINING_ID,
67 LEVEL_ID,
68 PERSON_ID,
69 FIELD_OF_LEARNING,
70 COURSE,
71 SUB_FIELD,
72 CREDIT,
73 NOTIONAL_HOURS,
74 REGISTRATION_DATE,
75 REGISTRATION_NUMBER
76 )
77 Values
78 (
79 p_rec.TRAINING_ID,
80 p_rec.LEVEL_ID,
81 p_rec.PERSON_ID,
82 p_rec.FIELD_OF_LEARNING,
83 p_rec.COURSE,
84 p_rec.SUB_FIELD,
85 p_rec.CREDIT,
86 p_rec.NOTIONAL_HOURS,
87 p_rec.REGISTRATION_DATE,
88 p_rec.REGISTRATION_NUMBER
89 );
90 --
91 per_za_tra_shd.g_api_dml := false; -- Unset the api dml status
92 --
93 hr_utility.set_location(' Leaving:'||l_proc, 10);
94 Exception
95 When hr_api.check_integrity_violated Then
96 -- A check constraint has been violated
97 per_za_tra_shd.g_api_dml := false; -- Unset the api dml status
98 per_za_tra_shd.constraint_error
99 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
100 When hr_api.parent_integrity_violated Then
101 -- Parent integrity has been violated
102 per_za_tra_shd.g_api_dml := false; -- Unset the api dml status
103 per_za_tra_shd.constraint_error
104 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
105 When hr_api.unique_integrity_violated Then
106 -- Unique integrity has been violated
107 per_za_tra_shd.g_api_dml := false; -- Unset the api dml status
108 per_za_tra_shd.constraint_error
109 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
110 When Others Then
111 per_za_tra_shd.g_api_dml := false; -- Unset the api dml status
112 Raise;
113 End insert_dml;
114
115 -- ----------------------------------------------------------------------------
116 -- |-----------------------------< post_insert >------------------------------|
117 -- ----------------------------------------------------------------------------
118 -- {Start Of Comments}
119 --
120 -- Description:
121 -- This private procedure contains any processing which is required after the
122 -- insert dml.
123 --
124 -- Pre Conditions:
125 -- This is an internal procedure which is called from the ins procedure.
126 --
127 -- In Parameters:
128 -- A Pl/Sql record structre.
129 --
130 -- Post Success:
131 -- Processing continues.
132 --
133 -- Post Failure:
134 -- If an error has occurred, an error message and exception will be raised
135 -- but not handled.
136 --
137 -- Developer Implementation Notes:
138 -- Any post-processing required after the insert dml is issued should be
139 -- coded within this procedure. It is important to note that any 3rd party
140 -- maintenance should be reviewed before placing in this procedure.
141 --
142 -- Access Status:
143 -- Internal Table Handler Use Only.
144 --
145 -- {End Of Comments}
146 -- ----------------------------------------------------------------------------
147 Procedure post_insert(p_rec in per_za_tra_shd.g_za_rec_type) is
148 --
149 l_proc varchar2(72) := g_package||'post_insert';
150 --
151 Begin
152 hr_utility.set_location('Entering:'||l_proc, 5);
153 --
154 hr_utility.set_location(' Leaving:'||l_proc, 10);
155 End post_insert;
156 --
157 -- ----------------------------------------------------------------------------
158 -- |---------------------------------< ins >----------------------------------|
159 -- ----------------------------------------------------------------------------
160 Procedure ins
161 (
162 p_rec in out nocopy per_za_tra_shd.g_za_rec_type,
163 p_validate in boolean default false
164 ) is
165 --
166 l_proc varchar2(72) := g_package||'ins';
167 --
168 Begin
169 hr_utility.set_location('Entering:'||l_proc, 5);
170 --
171 -- Determine if the business process is to be validated.
172 --
173 If p_validate then
174 --
175 -- Issue the savepoint.
176 --
177 SAVEPOINT ins_tra;
178 End If;
179
180 --
181 -- Insert the row
182 --
183 insert_dml(p_rec);
184 --
185 -- Call the supporting post-insert operation
186 --
187 post_insert(p_rec);
188 --
189 -- If we are validating then raise the Validate_Enabled exception
190 --
191 If p_validate then
192 Raise HR_Api.Validate_Enabled;
193 End If;
194 --
195 hr_utility.set_location(' Leaving:'||l_proc, 10);
196 Exception
197 When HR_Api.Validate_Enabled Then
198 --
199 -- As the Validate_Enabled exception has been raised
200 -- we must rollback to the savepoint
201 --
202 ROLLBACK TO ins_tra;
203 end ins;
204 --
205 -- ----------------------------------------------------------------------------
206 -- |---------------------------------< ins >----------------------------------|
207 -- ----------------------------------------------------------------------------
208 Procedure ins
209 (
210 P_TRAINING_ID IN NUMBER,
211 P_LEVEL_ID IN NUMBER default null,
212 P_PERSON_ID IN NUMBER,
213 P_FIELD_OF_LEARNING IN VARCHAR2 default null,
214 P_COURSE IN VARCHAR2 default null,
215 P_SUB_FIELD IN VARCHAR2 default null,
216 P_CREDIT IN NUMBER default null,
217 P_REGISTRATION_DATE IN DATE default null,
218 P_REGISTRATION_NUMBER IN VARCHAR2 default null,
219 P_NOTIONAL_HOURS IN NUMBER default null,
220 p_validate in boolean default false
221 ) is
222 --
223 l_rec per_za_tra_shd.g_za_rec_type;
224 l_proc varchar2(72) := g_package||'ins';
225 --
226 Begin
227 hr_utility.set_location('Entering:'||l_proc, 5);
228 --
229 -- Call conversion function to turn arguments into the
230 -- p_rec structure.
231 --
232 l_rec :=
233 per_za_tra_shd.convert_args
234 (
235 P_TRAINING_ID,
236 P_LEVEL_ID,
237 P_PERSON_ID,
238 P_FIELD_OF_LEARNING,
239 P_COURSE,
240 P_SUB_FIELD,
241 P_CREDIT,
242 P_NOTIONAL_HOURS,
243 P_REGISTRATION_DATE,
244 P_REGISTRATION_NUMBER
245 );
246 --
247 -- Having converted the arguments into the tra_rec
248 -- plsql record structure we call the corresponding record business process.
249 --
250 ins(l_rec, p_validate);
251 --
252 -- As the primary key argument(s)
253 -- are specified as an OUT's we must set these values.
254 --
255 --
256 hr_utility.set_location(' Leaving:'||l_proc, 10);
257 End ins;
258 --
259 end per_za_tra_ins;