DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_TCO_INS

Source


1 Package Body pay_tco_ins as
2 /* $Header: pytcorhi.pkb 120.0 2005/05/29 09:01:02 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  pay_tco_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 insert the row into the schema.
21 --   3) To trap any constraint violations that may have occurred.
22 --   4) To raise any other errors.
23 --
24 -- Prerequisites:
25 --   This is an internal private procedure which must be called from the ins
26 --   procedure and must have all mandatory attributes set (except the
27 --   object_version_number which is initialised within this procedure).
28 --
29 -- In Parameters:
30 --   A Pl/Sql record structre.
31 --
32 -- Post Success:
33 --   The specified row will be inserted into the schema.
34 --
35 -- Post Failure:
36 --   If a check, unique or parent integrity constraint violation is raised the
37 --   constraint_error procedure will be called.
38 --
39 -- Developer Implementation Notes:
40 --   None.
41 --
42 -- Access Status:
43 --   Internal Row Handler Use Only.
44 --
45 -- {End Of Comments}
46 -- ----------------------------------------------------------------------------
47 Procedure insert_dml(p_rec in out nocopy pay_tco_shd.g_rec_type) is
48 --
49   l_proc  varchar2(72) := g_package||'insert_dml';
50 --
51 Begin
52   hr_utility.set_location('Entering:'||l_proc, 5);
53   p_rec.object_version_number := 1;  -- Initialise the object version
54   --
55   -- Insert the row into: pay_template_core_objects
56   --
57   insert into pay_template_core_objects
58   (	template_core_object_id,
59 	template_id,
60 	core_object_type,
61 	core_object_id,
62 	shadow_object_id,
63 	effective_date,
64 	object_version_number
65   )
66   Values
67   (	p_rec.template_core_object_id,
68 	p_rec.template_id,
69 	p_rec.core_object_type,
70 	p_rec.core_object_id,
71 	p_rec.shadow_object_id,
72 	p_rec.effective_date,
73 	p_rec.object_version_number
74   );
75   --
76   hr_utility.set_location(' Leaving:'||l_proc, 10);
77 Exception
78   When hr_api.check_integrity_violated Then
79     -- A check constraint has been violated
80     pay_tco_shd.constraint_error
81       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
82   When hr_api.parent_integrity_violated Then
83     -- Parent integrity has been violated
84     pay_tco_shd.constraint_error
85       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
86   When hr_api.unique_integrity_violated Then
87     -- Unique integrity has been violated
88     pay_tco_shd.constraint_error
89       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
90   When Others Then
91     Raise;
92 End insert_dml;
93 --
94 -- ----------------------------------------------------------------------------
95 -- |------------------------------< pre_insert >------------------------------|
96 -- ----------------------------------------------------------------------------
97 -- {Start Of Comments}
98 --
99 -- Description:
100 --   This private procedure contains any processing which is required before
101 --   the insert dml. Presently, if the entity has a corresponding primary
102 --   key which is maintained by an associating sequence, the primary key for
103 --   the entity will be populated with the next sequence value in
104 --   preparation for the insert dml.
105 --
106 -- Prerequisites:
107 --   This is an internal procedure which is called from the ins procedure.
108 --
109 -- In Parameters:
110 --   A Pl/Sql record structre.
111 --
112 -- Post Success:
113 --   Processing continues.
114 --
115 -- Post Failure:
116 --   If an error has occurred, an error message and exception will be raised
117 --   but not handled.
118 --
119 -- Developer Implementation Notes:
120 --   Any pre-processing required before the insert dml is issued should be
121 --   coded within this procedure. As stated above, a good example is the
122 --   generation of a primary key number via a corresponding sequence.
123 --   It is important to note that any 3rd party maintenance should be reviewed
124 --   before placing in this procedure.
125 --
126 -- Access Status:
127 --   Internal Row Handler Use Only.
128 --
129 -- {End Of Comments}
130 -- ----------------------------------------------------------------------------
131 Procedure pre_insert(p_rec  in out nocopy pay_tco_shd.g_rec_type) is
132 --
133   l_proc  varchar2(72) := g_package||'pre_insert';
134 --
135   Cursor C_Sel1 is select pay_template_core_objects_s.nextval from sys.dual;
136 --
137 Begin
138   hr_utility.set_location('Entering:'||l_proc, 5);
139   --
140   --
141   -- Select the next sequence number
142   --
143   Open C_Sel1;
144   Fetch C_Sel1 Into p_rec.template_core_object_id;
145   Close C_Sel1;
146   --
147   hr_utility.set_location(' Leaving:'||l_proc, 10);
148 End pre_insert;
149 --
150 -- ----------------------------------------------------------------------------
151 -- |-----------------------------< post_insert >------------------------------|
152 -- ----------------------------------------------------------------------------
153 -- {Start Of Comments}
154 --
155 -- Description:
156 --   This private procedure contains any processing which is required after the
157 --   insert dml.
158 --
159 -- Prerequisites:
160 --   This is an internal procedure which is called from the ins procedure.
161 --
162 -- In Parameters:
163 --   A Pl/Sql record structre.
164 --
165 -- Post Success:
166 --   Processing continues.
167 --
168 -- Post Failure:
169 --   If an error has occurred, an error message and exception will be raised
170 --   but not handled.
171 --
172 -- Developer Implementation Notes:
173 --   Any post-processing required after the insert dml is issued should be
174 --   coded within this procedure. It is important to note that any 3rd party
175 --   maintenance should be reviewed before placing in this procedure.
176 --
177 -- Access Status:
178 --   Internal Row Handler Use Only.
179 --
180 -- {End Of Comments}
181 -- ----------------------------------------------------------------------------
182 Procedure post_insert(p_rec in pay_tco_shd.g_rec_type) is
183 --
184   l_proc  varchar2(72) := g_package||'post_insert';
185 --
186 Begin
187   hr_utility.set_location('Entering:'||l_proc, 5);
188   --
189   hr_utility.set_location(' Leaving:'||l_proc, 10);
190 End post_insert;
191 --
192 -- ----------------------------------------------------------------------------
193 -- |---------------------------------< ins >----------------------------------|
194 -- ----------------------------------------------------------------------------
195 Procedure ins
196   (
197   p_rec            in out nocopy pay_tco_shd.g_rec_type
198   ) is
199 --
200   l_proc  varchar2(72) := g_package||'ins';
201 --
202 Begin
203   hr_utility.set_location('Entering:'||l_proc, 5);
204   --
205   -- Call the supporting insert validate operations
206   --
207   pay_tco_bus.insert_validate(p_rec);
208   --
209   -- Call the supporting pre-insert operation
210   --
211   pre_insert(p_rec);
212   --
213   -- Insert the row
214   --
215   insert_dml(p_rec);
216   --
217   -- Call the supporting post-insert operation
218   --
219   post_insert(p_rec);
220 end ins;
221 --
222 -- ----------------------------------------------------------------------------
223 -- |---------------------------------< ins >----------------------------------|
224 -- ----------------------------------------------------------------------------
225 Procedure ins
226   (
227   p_template_core_object_id      out nocopy number,
228   p_template_id                  in number,
229   p_core_object_type             in varchar2,
230   p_core_object_id               in number,
231   p_shadow_object_id             in number,
232   p_effective_date               in date,
233   p_object_version_number        out nocopy number
234   ) is
235 --
236   l_rec	  pay_tco_shd.g_rec_type;
237   l_proc  varchar2(72) := g_package||'ins';
238 --
239 Begin
240   hr_utility.set_location('Entering:'||l_proc, 5);
241   --
242   -- Call conversion function to turn arguments into the
243   -- p_rec structure.
244   --
245   l_rec :=
246   pay_tco_shd.convert_args
247   (
248   null,
249   p_template_id,
250   p_core_object_type,
251   p_core_object_id,
252   p_shadow_object_id,
253   p_effective_date,
254   null
255   );
256   --
257   -- Having converted the arguments into the pay_tco_rec
261   --
258   -- plsql record structure we call the corresponding record business process.
259   --
260   ins(l_rec);
262   -- As the primary key argument(s)
263   -- are specified as an OUT's we must set these values.
264   --
265   p_template_core_object_id := l_rec.template_core_object_id;
266   p_object_version_number := l_rec.object_version_number;
267   --
268   hr_utility.set_location(' Leaving:'||l_proc, 10);
269 End ins;
270 --
271 end pay_tco_ins;