DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_RLT_INS

Source


1 Package Body pqh_rlt_ins as
2 /* $Header: pqrltrhi.pkb 115.8 2004/02/26 10:32:25 srajakum noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  pqh_rlt_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 --   3) To insert the row into the schema.
21 --   4) To trap any constraint violations that may have occurred.
22 --   5) 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_rlt_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_routing_lists
57   --
58   insert into pqh_routing_lists
59   (	routing_list_id,
60 	routing_list_name,
61 	enable_flag,
62 	object_version_number
63   )
64   Values
65   (	p_rec.routing_list_id,
66 	p_rec.routing_list_name,
67 	p_rec.enable_flag,
68 	p_rec.object_version_number
69   );
70   --
71   --
72   hr_utility.set_location(' Leaving:'||l_proc, 10);
73 Exception
74   When hr_api.check_integrity_violated Then
75     -- A check constraint has been violated
76     pqh_rlt_shd.constraint_error
77       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
78   When hr_api.parent_integrity_violated Then
79     -- Parent integrity has been violated
80     pqh_rlt_shd.constraint_error
81       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
82   When hr_api.unique_integrity_violated Then
83     -- Unique integrity has been violated
84     pqh_rlt_shd.constraint_error
85       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
86   When Others Then
87     Raise;
88 End insert_dml;
89 --
90 -- ----------------------------------------------------------------------------
91 -- |------------------------------< pre_insert >------------------------------|
92 -- ----------------------------------------------------------------------------
93 -- {Start Of Comments}
94 --
95 -- Description:
96 --   This private procedure contains any processing which is required before
97 --   the insert dml. Presently, if the entity has a corresponding primary
98 --   key which is maintained by an associating sequence, the primary key for
99 --   the entity will be populated with the next sequence value in
100 --   preparation for the insert dml.
101 --
102 -- Prerequisites:
103 --   This is an internal procedure which is called from the ins procedure.
104 --
105 -- In Parameters:
106 --   A Pl/Sql record structre.
107 --
108 -- Post Success:
109 --   Processing continues.
110 --
111 -- Post Failure:
112 --   If an error has occurred, an error message and exception will be raised
113 --   but not handled.
114 --
115 -- Developer Implementation Notes:
116 --   Any pre-processing required before the insert dml is issued should be
117 --   coded within this procedure. As stated above, a good example is the
118 --   generation of a primary key number via a corresponding sequence.
119 --   It is important to note that any 3rd party maintenance should be reviewed
120 --   before placing in this procedure.
121 --
122 -- Access Status:
123 --   Internal Row Handler Use Only.
124 --
125 -- {End Of Comments}
126 -- ----------------------------------------------------------------------------
127 Procedure pre_insert(p_rec  in out nocopy pqh_rlt_shd.g_rec_type) is
128 --
129   l_proc  varchar2(72) := g_package||'pre_insert';
130 --
131   Cursor C_Sel1 is select pqh_routing_lists_s.nextval from sys.dual;
132 --
133 Begin
134   hr_utility.set_location('Entering:'||l_proc, 5);
135   --
136   --
137   -- Select the next sequence number
138   --
139   Open C_Sel1;
140   Fetch C_Sel1 Into p_rec.routing_list_id;
141   Close C_Sel1;
142   --
143   hr_utility.set_location(' Leaving:'||l_proc, 10);
144 End pre_insert;
145 --
146 -- ----------------------------------------------------------------------------
147 -- |-----------------------------< post_insert >------------------------------|
148 -- ----------------------------------------------------------------------------
149 -- {Start Of Comments}
150 --
151 -- Description:
152 --   This private procedure contains any processing which is required after the
153 --   insert dml.
154 --
155 -- Prerequisites:
156 --   This is an internal procedure which is called from the ins procedure.
157 --
158 -- In Parameters:
159 --   A Pl/Sql record structre.
160 --
161 -- Post Success:
162 --   Processing continues.
163 --
164 -- Post Failure:
165 --   If an error has occurred, an error message and exception will be raised
166 --   but not handled.
167 --
168 -- Developer Implementation Notes:
169 --   Any post-processing required after the insert dml is issued should be
170 --   coded within this procedure. It is important to note that any 3rd party
171 --   maintenance should be reviewed before placing in this procedure.
172 --
173 -- Access Status:
174 --   Internal Row Handler Use Only.
175 --
176 -- {End Of Comments}
177 -- ----------------------------------------------------------------------------
178 Procedure post_insert(p_rec in pqh_rlt_shd.g_rec_type) is
179 --
180   l_proc  varchar2(72) := g_package||'post_insert';
181 --
182 Begin
183   hr_utility.set_location('Entering:'||l_proc, 5);
184 --
185   --
186   -- Start of API User Hook for post_insert.
187   --
188   begin
189     --
190     pqh_rlt_rki.after_insert
191       (
192   p_routing_list_id               =>p_rec.routing_list_id
193  ,p_routing_list_name             =>p_rec.routing_list_name
194  ,p_enable_flag			  =>p_rec.enable_flag
195  ,p_object_version_number         =>p_rec.object_version_number
196       );
197     --
198   exception
199     --
200     when hr_api.cannot_find_prog_unit then
201       --
202       hr_api.cannot_find_prog_unit_error
203         (p_module_name => 'pqh_routing_lists'
204         ,p_hook_type   => 'AI');
205       --
206   end;
207   --
208   -- End of API User Hook for post_insert.
209   --
210   --
211   hr_utility.set_location(' Leaving:'||l_proc, 10);
212 End post_insert;
213 --
214 -- ----------------------------------------------------------------------------
215 -- |---------------------------------< ins >----------------------------------|
216 -- ----------------------------------------------------------------------------
217 Procedure ins
218   (
219   p_rec        in out nocopy pqh_rlt_shd.g_rec_type
220   ) is
221 --
222   l_proc  varchar2(72) := g_package||'ins';
223 --
224 Begin
225   hr_utility.set_location('Entering:'||l_proc, 5);
226   --
227   -- Call the supporting insert validate operations
228   --
229   pqh_rlt_bus.insert_validate(p_rec);
230   --
231   -- Call the supporting pre-insert operation
232   --
233   pre_insert(p_rec);
234   --
235   -- Insert the row
236   --
237   insert_dml(p_rec);
238   --
239   -- Call the supporting post-insert operation
240   --
241   post_insert(p_rec);
242 end ins;
243 --
244 -- ----------------------------------------------------------------------------
245 -- |---------------------------------< ins >----------------------------------|
246 -- ----------------------------------------------------------------------------
247 Procedure ins
248   (
249   p_routing_list_id              out nocopy number,
250   p_routing_list_name            in varchar2         default null,
251   p_enable_flag			 in varchar2		default 'Y',
252   p_object_version_number        out nocopy number
253   ) is
254 --
255   l_rec	  pqh_rlt_shd.g_rec_type;
256   l_proc  varchar2(72) := g_package||'ins';
257 --
258 Begin
259   hr_utility.set_location('Entering:'||l_proc, 5);
260   --
261   -- Call conversion function to turn arguments into the
262   -- p_rec structure.
263   --
264   l_rec :=
265   pqh_rlt_shd.convert_args
266   (
267   null,
268   p_routing_list_name,
269   p_enable_flag,
270   null
271   );
272   --
273   -- Having converted the arguments into the pqh_rlt_rec
274   -- plsql record structure we call the corresponding record business process.
275   --
276   ins(l_rec);
277   --
278   -- As the primary key argument(s)
279   -- are specified as an OUT's we must set these values.
280   --
281   p_routing_list_id := l_rec.routing_list_id;
282   p_object_version_number := l_rec.object_version_number;
283   --
284   hr_utility.set_location(' Leaving:'||l_proc, 10);
285 End ins;
286 --
287 end pqh_rlt_ins;