DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_PAP_INS

Source


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