DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_TRV_INS

Source


1 Package Body hr_trv_ins as
2 /* $Header: hrtrvrhi.pkb 115.2 99/10/04 06:00:25 porting ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  hr_trv_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 hr_trv_shd.g_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   hr_trv_shd.g_api_dml := true;  -- Set the api dml status
62   --
63   -- Insert the row into: hr_api_transaction_values
64   --
65   insert into hr_api_transaction_values
66   ( transaction_value_id,
67     transaction_step_id,
68     datatype,
69     name,
70     varchar2_value,
71     number_value,
72     date_value,
73     original_varchar2_value,
74     original_number_value,
75     original_date_value
76   )
77   Values
78   ( p_rec.transaction_value_id,
79     p_rec.transaction_step_id,
80     p_rec.datatype,
81     p_rec.name,
82     p_rec.varchar2_value,
83     p_rec.number_value,
84     p_rec.date_value,
85     p_rec.original_varchar2_value,
86     p_rec.original_number_value,
87     p_rec.original_date_value
88   );
89   --
90   hr_trv_shd.g_api_dml := false;   -- Unset the api dml status
91   --
92   hr_utility.set_location(' Leaving:'||l_proc, 10);
93 Exception
94   When hr_api.check_integrity_violated Then
95     -- A check constraint has been violated
96     hr_trv_shd.g_api_dml := false;   -- Unset the api dml status
97     hr_trv_shd.constraint_error
98       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
99   When hr_api.parent_integrity_violated Then
100     -- Parent integrity has been violated
101     hr_trv_shd.g_api_dml := false;   -- Unset the api dml status
102     hr_trv_shd.constraint_error
103       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
104   When hr_api.unique_integrity_violated Then
105     -- Unique integrity has been violated
106     hr_trv_shd.g_api_dml := false;   -- Unset the api dml status
107     hr_trv_shd.constraint_error
108       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
109   When Others Then
110     hr_trv_shd.g_api_dml := false;   -- Unset the api dml status
111     Raise;
112 End insert_dml;
113 --
114 -- ----------------------------------------------------------------------------
115 -- |------------------------------< pre_insert >------------------------------|
116 -- ----------------------------------------------------------------------------
117 -- {Start Of Comments}
118 --
119 -- Description:
120 --   This private procedure contains any processing which is required before
121 --   the insert dml. Presently, if the entity has a corresponding primary
122 --   key which is maintained by an associating sequence, the primary key for
123 --   the entity will be populated with the next sequence value in
124 --   preparation for the insert dml.
125 --
126 -- Pre Conditions:
127 --   This is an internal procedure which is called from the ins procedure.
128 --
129 -- In Parameters:
130 --   A Pl/Sql record structre.
131 --
132 -- Post Success:
133 --   Processing continues.
134 --
135 -- Post Failure:
136 --   If an error has occurred, an error message and exception will be raised
137 --   but not handled.
138 --
139 -- Developer Implementation Notes:
140 --   Any pre-processing required before the insert dml is issued should be
141 --   coded within this procedure. As stated above, a good example is the
142 --   generation of a primary key number via a corresponding sequence.
143 --   It is important to note that any 3rd party maintenance should be reviewed
144 --   before placing in this procedure.
145 --
146 -- Access Status:
147 --   Internal Table Handler Use Only.
148 --
149 -- {End Of Comments}
150 -- ----------------------------------------------------------------------------
151 Procedure pre_insert(p_rec  in out hr_trv_shd.g_rec_type) is
152 --
153   l_proc  varchar2(72) := g_package||'pre_insert';
154 --
155   Cursor C_Sel1 is select hr_api_transaction_values_s.nextval from sys.dual;
156 --
157 Begin
158   hr_utility.set_location('Entering:'||l_proc, 5);
159   --
160   --
161   -- Select the next sequence number
162   --
163   Open C_Sel1;
164   Fetch C_Sel1 Into p_rec.transaction_value_id;
165   Close C_Sel1;
166   --
167   hr_utility.set_location(' Leaving:'||l_proc, 10);
168 End pre_insert;
169 --
170 -- ----------------------------------------------------------------------------
171 -- |-----------------------------< post_insert >------------------------------|
172 -- ----------------------------------------------------------------------------
173 -- {Start Of Comments}
174 --
175 -- Description:
176 --   This private procedure contains any processing which is required after the
177 --   insert dml.
178 --
179 -- Pre Conditions:
180 --   This is an internal procedure which is called from the ins procedure.
181 --
182 -- In Parameters:
183 --   A Pl/Sql record structre.
184 --
185 -- Post Success:
186 --   Processing continues.
187 --
188 -- Post Failure:
189 --   If an error has occurred, an error message and exception will be raised
190 --   but not handled.
191 --
192 -- Developer Implementation Notes:
193 --   Any post-processing required after the insert dml is issued should be
194 --   coded within this procedure. It is important to note that any 3rd party
195 --   maintenance should be reviewed before placing in this procedure.
196 --
197 -- Access Status:
198 --   Internal Table Handler Use Only.
199 --
200 -- {End Of Comments}
201 -- ----------------------------------------------------------------------------
202 Procedure post_insert(p_rec in hr_trv_shd.g_rec_type) is
203 --
204   l_proc  varchar2(72) := g_package||'post_insert';
205 --
206 Begin
207   hr_utility.set_location('Entering:'||l_proc, 5);
208   --
209   hr_utility.set_location(' Leaving:'||l_proc, 10);
210 End post_insert;
211 --
212 -- ----------------------------------------------------------------------------
213 -- |---------------------------------< ins >----------------------------------|
214 -- ----------------------------------------------------------------------------
215 Procedure ins
216   (
217   p_rec        in out hr_trv_shd.g_rec_type,
218   p_validate   in     boolean default false
219   ) is
220 --
221   l_proc  varchar2(72) := g_package||'ins';
222 --
223 Begin
224   hr_utility.set_location('Entering:'||l_proc, 5);
225   --
226   -- Determine if the business process is to be validated.
227   --
228   If p_validate then
229     --
230     -- Issue the savepoint.
231     --
232     SAVEPOINT ins_hr_trv;
233   End If;
234   --
235   -- Call the supporting insert validate operations
236   --
237   hr_trv_bus.insert_validate(p_rec);
238   --
239   -- Call the supporting pre-insert operation
240   --
241   pre_insert(p_rec);
242   --
243   -- Insert the row
244   --
245   insert_dml(p_rec);
246   --
247   -- Call the supporting post-insert operation
248   --
249   post_insert(p_rec);
250   --
251   -- If we are validating then raise the Validate_Enabled exception
252   --
253   If p_validate then
254     Raise HR_Api.Validate_Enabled;
255   End If;
256   --
257   hr_utility.set_location(' Leaving:'||l_proc, 10);
258 Exception
259   When HR_Api.Validate_Enabled Then
260     --
261     -- As the Validate_Enabled exception has been raised
262     -- we must rollback to the savepoint
263     --
264     ROLLBACK TO ins_hr_trv;
265 end ins;
266 --
267 -- ----------------------------------------------------------------------------
268 -- |---------------------------------< ins >----------------------------------|
269 -- ----------------------------------------------------------------------------
270 Procedure ins
271   (
272   p_transaction_value_id         out number,
273   p_transaction_step_id          in number,
274   p_datatype                     in varchar2,
275   p_name                         in varchar2,
276   p_varchar2_value               in varchar2         default null,
277   p_number_value                 in number           default null,
278   p_date_value                   in date             default null,
279   p_original_varchar2_value      in varchar2         default null,
280   p_original_number_value        in number           default null,
281   p_original_date_value          in date             default null,
282   p_validate                     in boolean   default false
283   ) is
284 --
285   l_rec   hr_trv_shd.g_rec_type;
286   l_proc  varchar2(72) := g_package||'ins';
287 --
288 Begin
289   hr_utility.set_location('Entering:'||l_proc, 5);
290   --
291   -- Call conversion function to turn arguments into the
292   -- p_rec structure.
293   --
294   l_rec :=
295   hr_trv_shd.convert_args
296   (
297   null,
298   p_transaction_step_id,
299   p_datatype,
300   p_name,
301   p_varchar2_value,
302   p_number_value,
303   p_date_value,
304   p_original_varchar2_value,
305   p_original_number_value,
306   p_original_date_value
307   );
308   --
309   -- Having converted the arguments into the hr_trv_rec
310   -- plsql record structure we call the corresponding record business process.
311   --
312   ins(l_rec, p_validate);
313   --
314   -- As the primary key argument(s)
315   -- are specified as an OUT's we must set these values.
316   --
317   p_transaction_value_id := l_rec.transaction_value_id;
318   --
319   --
320   hr_utility.set_location(' Leaving:'||l_proc, 10);
321 End ins;
322 --
323 end hr_trv_ins;