DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_ATT_INS

Source


1 Package Body pqh_att_ins as
2 /* $Header: pqattrhi.pkb 120.3.12000000.2 2007/04/19 12:37:00 brsinha noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  pqh_att_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 pqh_att_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   --
56   -- Insert the row into: pqh_attributes
57   --
58   insert into pqh_attributes
59   (	attribute_id,
60 	attribute_name,
61 	master_attribute_id,
62 	master_table_route_id,
63 	column_name,
64 	column_type,
65 	enable_flag,
66 	width,
67 	object_version_number,
68         region_itemname,
69         attribute_itemname,
70         decode_function_name
71   )
72   Values
73   (	p_rec.attribute_id,
74 	p_rec.attribute_name,
75 	p_rec.master_attribute_id,
76 	p_rec.master_table_route_id,
77 	p_rec.column_name,
78 	p_rec.column_type,
79 	p_rec.enable_flag,
80 	p_rec.width,
81 	p_rec.object_version_number,
82         p_rec.region_itemname,
83         p_rec.attribute_itemname,
84         p_rec.decode_function_name
85   );
86   --
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     pqh_att_shd.constraint_error
93       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
94   When hr_api.parent_integrity_violated Then
95     -- Parent integrity has been violated
96     pqh_att_shd.constraint_error
97       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
98   When hr_api.unique_integrity_violated Then
99     -- Unique integrity has been violated
100     pqh_att_shd.constraint_error
101       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
102   When Others Then
103     Raise;
104 End insert_dml;
105 --
106 -- ----------------------------------------------------------------------------
107 -- |------------------------------< pre_insert >------------------------------|
108 -- ----------------------------------------------------------------------------
109 -- {Start Of Comments}
110 --
111 -- Description:
112 --   This private procedure contains any processing which is required before
113 --   the insert dml. Presently, if the entity has a corresponding primary
114 --   key which is maintained by an associating sequence, the primary key for
115 --   the entity will be populated with the next sequence value in
116 --   preparation for the insert dml.
117 --
118 -- Prerequisites:
119 --   This is an internal procedure which is called from the ins procedure.
120 --
121 -- In Parameters:
122 --   A Pl/Sql record structre.
123 --
124 -- Post Success:
125 --   Processing continues.
126 --
127 -- Post Failure:
128 --   If an error has occurred, an error message and exception will be raised
129 --   but not handled.
130 --
131 -- Developer Implementation Notes:
132 --   Any pre-processing required before the insert dml is issued should be
133 --   coded within this procedure. As stated above, a good example is the
134 --   generation of a primary key number via a corresponding sequence.
135 --   It is important to note that any 3rd party maintenance should be reviewed
136 --   before placing in this procedure.
137 --
138 -- Access Status:
139 --   Internal Row Handler Use Only.
140 --
141 -- {End Of Comments}
142 -- ----------------------------------------------------------------------------
143 Procedure pre_insert(p_rec  in out nocopy pqh_att_shd.g_rec_type) is
144 --
145   l_proc  varchar2(72) := g_package||'pre_insert';
146 --
147   Cursor C_Sel1 is select pqh_attributes_s.nextval from sys.dual;
148 --
149 Begin
150   hr_utility.set_location('Entering:'||l_proc, 5);
151   --
152   --
153   -- Select the next sequence number
154   --
155   Open C_Sel1;
156   Fetch C_Sel1 Into p_rec.attribute_id;
157   Close C_Sel1;
158   --
159   hr_utility.set_location(' Leaving:'||l_proc, 10);
160 End pre_insert;
161 --
162 -- ----------------------------------------------------------------------------
163 -- |-----------------------------< post_insert >------------------------------|
164 -- ----------------------------------------------------------------------------
165 -- {Start Of Comments}
166 --
167 -- Description:
168 --   This private procedure contains any processing which is required after the
169 --   insert dml.
170 --
171 -- Prerequisites:
172 --   This is an internal procedure which is called from the ins procedure.
173 --
174 -- In Parameters:
175 --   A Pl/Sql record structre.
176 --
177 -- Post Success:
178 --   Processing continues.
179 --
180 -- Post Failure:
181 --   If an error has occurred, an error message and exception will be raised
182 --   but not handled.
183 --
184 -- Developer Implementation Notes:
185 --   Any post-processing required after the insert dml is issued should be
186 --   coded within this procedure. It is important to note that any 3rd party
187 --   maintenance should be reviewed before placing in this procedure.
188 --
189 -- Access Status:
190 --   Internal Row Handler Use Only.
191 --
192 -- {End Of Comments}
193 -- ----------------------------------------------------------------------------
194 Procedure post_insert(
195 p_effective_date in date,p_rec in pqh_att_shd.g_rec_type) is
196 --
197   l_proc  varchar2(72) := g_package||'post_insert';
198 --
199 Begin
200   hr_utility.set_location('Entering:'||l_proc, 5);
201 --
202   --
203   -- Start of API User Hook for post_insert.
204   --
205   begin
206     --
207     pqh_att_rki.after_insert
208       (
209   p_attribute_id                  => p_rec.attribute_id
210  ,p_attribute_name                => p_rec.attribute_name
211  ,p_master_attribute_id           => p_rec.master_attribute_id
212  ,p_master_table_route_id         => p_rec.master_table_route_id
213  ,p_column_name                   => p_rec.column_name
214  ,p_column_type                   => p_rec.column_type
215  ,p_enable_flag                   => p_rec.enable_flag
216  ,p_width                         => p_rec.width
217  ,p_object_version_number         => p_rec.object_version_number
218  ,p_effective_date                => p_effective_date
219  ,p_region_itemname               => p_rec.region_itemname
220  ,p_attribute_itemname            => p_rec.attribute_itemname
221  ,p_decode_function_name          => p_rec.decode_function_name
222       );
223     --
224   exception
225     --
226     when hr_api.cannot_find_prog_unit then
227       --
228       hr_api.cannot_find_prog_unit_error
229         (p_module_name => 'pqh_attributes'
230         ,p_hook_type   => 'AI');
231       --
232   end;
233   --
234   -- End of API User Hook for post_insert.
235   --
236   --
237   hr_utility.set_location(' Leaving:'||l_proc, 10);
238 End post_insert;
239 --
240 -- ----------------------------------------------------------------------------
241 -- |---------------------------------< ins >----------------------------------|
242 -- ----------------------------------------------------------------------------
243 Procedure ins
244   (
245   p_effective_date in date,
246   p_rec        in out nocopy pqh_att_shd.g_rec_type
247   ) is
248 --
249   l_proc  varchar2(72) := g_package||'ins';
250 --
251 Begin
252   hr_utility.set_location('Entering:'||l_proc, 5);
253   --
254   -- Call the supporting insert validate operations
255   --
256   pqh_att_bus.insert_validate(p_rec
257   ,p_effective_date);
258   --
259   -- Call the supporting pre-insert operation
260   --
261   pre_insert(p_rec);
262   --
263   -- Insert the row
264   --
265   insert_dml(p_rec);
266   --
267   -- Call the supporting post-insert operation
268   --
269   post_insert(
270 p_effective_date,p_rec);
271 end ins;
272 --
273 -- ----------------------------------------------------------------------------
274 -- |---------------------------------< ins >----------------------------------|
275 -- ----------------------------------------------------------------------------
276 Procedure ins
277   (
278   p_effective_date in date,
279   p_attribute_id                 out nocopy number,
280   p_attribute_name               in varchar2,
281   p_master_attribute_id          in number           default null,
282   p_master_table_route_id        in number,
283   p_column_name                  in varchar2,
284   p_column_type                  in varchar2,
285   p_enable_flag                  in varchar2         default null,
286   p_width                        in number,
287   p_object_version_number        out nocopy number,
288   p_region_itemname              in varchar2,
289   p_attribute_itemname           in varchar2,
290   p_decode_function_name         in varchar2
291   ) is
292 --
293   l_rec	  pqh_att_shd.g_rec_type;
294   l_proc  varchar2(72) := g_package||'ins';
295 --
296 Begin
297   hr_utility.set_location('Entering:'||l_proc, 5);
298   --
299   -- Call conversion function to turn arguments into the
300   -- p_rec structure.
301   --
302   l_rec :=
303   pqh_att_shd.convert_args
304   (
305   null,
306   p_attribute_name,
307   p_master_attribute_id,
308   p_master_table_route_id,
309   p_column_name,
310   p_column_type,
311   p_enable_flag,
312   p_width,
313   null,
314   p_region_itemname,
315   p_attribute_itemname,
316   p_decode_function_name
317   );
318   --
319   -- Having converted the arguments into the pqh_att_rec
320   -- plsql record structure we call the corresponding record business process.
321   --
322   ins(
323     p_effective_date,l_rec);
324   --
325   -- As the primary key argument(s)
326   -- are specified as an OUT's we must set these values.
327   --
328   p_attribute_id := l_rec.attribute_id;
329   p_object_version_number := l_rec.object_version_number;
330   --
331   hr_utility.set_location(' Leaving:'||l_proc, 10);
332 End ins;
333 --
334 end pqh_att_ins;