DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_ABM_INS

Source


1 Package Body hr_abm_ins as
2 /* $Header: hrabmrhi.pkb 115.4 99/10/12 07:03:51 porting ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  hr_abm_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_abm_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_abm_shd.g_api_dml := true;  -- Set the api dml status
62   --
63   -- Insert the row into: hr_api_batch_message_lines
64   --
65   insert into hr_api_batch_message_lines
66   (	line_id,
67 	batch_run_number,
68 	api_name,
69 	status,
70 	error_number,
71 	error_message,
72 	extended_error_message,
73 	source_row_information
74   )
75   Values
76   (	p_rec.line_id,
77 	p_rec.batch_run_number,
78 	p_rec.api_name,
79 	p_rec.status,
80 	p_rec.error_number,
81 	p_rec.error_message,
82 	p_rec.extended_error_message,
83 	p_rec.source_row_information
84   );
85   --
86   hr_abm_shd.g_api_dml := false;   -- Unset the api dml status
87   --
88   hr_utility.set_location(' Leaving:'||l_proc, 10);
89 Exception
90   When hr_api.check_integrity_violated Then
91     -- A check constraint has been violated
92     hr_abm_shd.g_api_dml := false;   -- Unset the api dml status
93     hr_abm_shd.constraint_error
94       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
95   When hr_api.parent_integrity_violated Then
96     -- Parent integrity has been violated
97     hr_abm_shd.g_api_dml := false;   -- Unset the api dml status
98     hr_abm_shd.constraint_error
99       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
100   When hr_api.unique_integrity_violated Then
101     -- Unique integrity has been violated
102     hr_abm_shd.g_api_dml := false;   -- Unset the api dml status
103     hr_abm_shd.constraint_error
104       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
105   When Others Then
106     hr_abm_shd.g_api_dml := false;   -- Unset the api dml status
107     Raise;
108 End insert_dml;
109 --
110 -- ----------------------------------------------------------------------------
111 -- |------------------------------< pre_insert >------------------------------|
112 -- ----------------------------------------------------------------------------
113 -- {Start Of Comments}
114 --
115 -- Description:
116 --   This private procedure contains any processing which is required before
117 --   the insert dml. Presently, if the entity has a corresponding primary
118 --   key which is maintained by an associating sequence, the primary key for
119 --   the entity will be populated with the next sequence value in
120 --   preparation for the insert dml.
121 --
122 -- Pre Conditions:
123 --   This is an internal procedure which is called from the ins procedure.
124 --
125 -- In Parameters:
126 --   A Pl/Sql record structre.
127 --
128 -- Post Success:
129 --   Processing continues.
130 --
131 -- Post Failure:
132 --   If an error has occurred, an error message and exception will be raised
133 --   but not handled.
134 --
135 -- Developer Implementation Notes:
136 --   Any pre-processing required before the insert dml is issued should be
137 --   coded within this procedure. As stated above, a good example is the
138 --   generation of a primary key number via a corresponding sequence.
139 --   It is important to note that any 3rd party maintenance should be reviewed
140 --   before placing in this procedure.
141 --
142 -- Access Status:
143 --   Internal Table Handler Use Only.
144 --
145 -- {End Of Comments}
146 -- ----------------------------------------------------------------------------
147 Procedure pre_insert(p_rec  in out hr_abm_shd.g_rec_type) is
148 --
149   l_proc  varchar2(72) := g_package||'pre_insert';
150 --
151   Cursor C_Sel1 is select hr_api_batch_message_lines_s.nextval from sys.dual;
152 --
153 Begin
154   hr_utility.set_location('Entering:'||l_proc, 5);
155   --
156   --
157   -- Select the next sequence number
158   --
159   Open C_Sel1;
160   Fetch C_Sel1 Into p_rec.line_id;
161   Close C_Sel1;
162   --
163   hr_utility.set_location(' Leaving:'||l_proc, 10);
164 End pre_insert;
165 --
166 -- ----------------------------------------------------------------------------
167 -- |---------------------------------< ins >----------------------------------|
168 -- ----------------------------------------------------------------------------
169 Procedure ins
170   (
171   p_rec        in out hr_abm_shd.g_rec_type,
175   l_proc  varchar2(72) := g_package||'ins';
172   p_validate   in     boolean default false
173   ) is
174 --
176 --
177 Begin
178   hr_utility.set_location('Entering:'||l_proc, 5);
179   --
180   -- Determine if the business process is to be validated.
181   --
182   If p_validate then
183     --
184     -- Issue the savepoint.
185     --
186     SAVEPOINT ins_hr_abm;
187   End If;
188   --
189   -- Call the supporting insert validate operations
190   --
191   hr_abm_bus.insert_validate(p_rec);
192   --
193   -- Call the supporting pre-insert operation
194   --
195   pre_insert(p_rec);
196   --
197   -- Insert the row
198   --
199   insert_dml(p_rec);
200   --
201   -- If we are validating then raise the Validate_Enabled exception
202   --
203   If p_validate then
204     Raise HR_Api.Validate_Enabled;
205   End If;
206   --
207   hr_utility.set_location(' Leaving:'||l_proc, 10);
208 Exception
209   When HR_Api.Validate_Enabled Then
210     --
211     -- As the Validate_Enabled exception has been raised
212     -- we must rollback to the savepoint
213     --
214     ROLLBACK TO ins_hr_abm;
215 end ins;
216 --
217 -- ----------------------------------------------------------------------------
218 -- |---------------------------------< ins >----------------------------------|
219 -- ----------------------------------------------------------------------------
220 Procedure ins
221   (
222   p_line_id                      out number,
223   p_batch_run_number             in number,
224   p_api_name                     in varchar2,
225   p_status                       in varchar2,
226   p_error_number                 in number           default null,
227   p_error_message                in varchar2         default null,
228   p_extended_error_message       in varchar2         default null,
229   p_source_row_information       in varchar2         default null,
230   p_validate                     in boolean   default false
231   ) is
232 --
233   l_rec	  hr_abm_shd.g_rec_type;
234   l_proc  varchar2(72) := g_package||'ins';
235 --
236 Begin
237   hr_utility.set_location('Entering:'||l_proc, 5);
238   --
239   -- Call conversion function to turn arguments into the
240   -- p_rec structure.
241   --
242   l_rec :=
243   hr_abm_shd.convert_args
244   (
245   null,
246   p_batch_run_number,
247   p_api_name,
248   p_status,
249   p_error_number,
250   p_error_message,
251   p_extended_error_message,
252   p_source_row_information
253   );
254   --
255   -- Having converted the arguments into the hr_abm_rec
256   -- plsql record structure we call the corresponding record business process.
257   --
258   ins(l_rec, p_validate);
259   --
260   -- As the primary key argument(s)
261   -- are specified as an OUT's we must set these values.
262   --
263   p_line_id := l_rec.line_id;
264   --
265   --
269 end hr_abm_ins;
266   hr_utility.set_location(' Leaving:'||l_proc, 10);
267 End ins;
268 --