DBA Data[Home] [Help]

PACKAGE BODY: APPS.FF_ARC_INS

Source


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