DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_ZA_LSA_INS

Source


1 Package Body per_za_lsa_ins as
2 /* $Header: pezalsin.pkb 115.1 2002/12/05 06:50:18 nsugavan noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  per_za_lsa_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 nocopy per_za_lsa_shd.g_za_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 
60   --
61   per_za_lsa_shd.g_api_dml := true;  -- Set the api dml status
62   --
63   -- Insert the row into: per_za_assessments
64   --
65   insert into per_za_learnership_agreements(
66     AGREEMENT_ID,
67     NAME,
68     DESCRIPTION,
69     AGREEMENT_NUMBER,
70     PERSON_ID,
71     AGREEMENT_START_DATE,
72     AGREEMENT_END_DATE,
73     STATUS,
74     SETA,
75     PROBATIONARY_END_DATE,
76     TERMINATED_BY,
77     LEARNER_TYPE,
78     REASON_FOR_TERMINATION,
79     ACTUAL_END_DATE,
80     AGREEMENT_HARD_COPY_ID
81   )
82   Values
83   (
84     p_rec.AGREEMENT_ID,
85     p_rec.NAME,
86     p_rec.DESCRIPTION,
87     p_rec.AGREEMENT_NUMBER,
88     p_rec.PERSON_ID,
89     p_rec.AGREEMENT_START_DATE,
90     p_rec.AGREEMENT_END_DATE,
91     p_rec.STATUS,
92     p_rec.SETA,
93     p_rec.PROBATIONARY_END_DATE,
94     p_rec.TERMINATED_BY,
95     p_rec.LEARNER_TYPE,
96     p_rec.REASON_FOR_TERMINATION,
97     p_rec.ACTUAL_END_DATE,
98     p_rec.AGREEMENT_HARD_COPY_ID
99   );
100   --
101   per_za_lsa_shd.g_api_dml := false;   -- Unset the api dml status
102   --
103   hr_utility.set_location(' Leaving:'||l_proc, 10);
104 Exception
105   When hr_api.check_integrity_violated Then
106     -- A check constraint has been violated
107     per_za_lsa_shd.g_api_dml := false;   -- Unset the api dml status
108     per_za_lsa_shd.constraint_error
109       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
110   When hr_api.parent_integrity_violated Then
111     -- Parent integrity has been violated
112     per_za_lsa_shd.g_api_dml := false;   -- Unset the api dml status
113     per_za_lsa_shd.constraint_error
114       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
115   When hr_api.unique_integrity_violated Then
116     -- Unique integrity has been violated
117     per_za_lsa_shd.g_api_dml := false;   -- Unset the api dml status
118     per_za_lsa_shd.constraint_error
119       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
120   When Others Then
121     per_za_lsa_shd.g_api_dml := false;   -- Unset the api dml status
122     Raise;
123 End insert_dml;
124 
125 -- ----------------------------------------------------------------------------
126 -- |-----------------------------< post_insert >------------------------------|
127 -- ----------------------------------------------------------------------------
128 -- {Start Of Comments}
129 --
130 -- Description:
131 --   This private procedure contains any processing which is required after the
132 --   insert dml.
133 --
134 -- Pre Conditions:
135 --   This is an internal procedure which is called from the ins procedure.
136 --
137 -- In Parameters:
138 --   A Pl/Sql record structre.
139 --
140 -- Post Success:
141 --   Processing continues.
142 --
143 -- Post Failure:
144 --   If an error has occurred, an error message and exception will be raised
145 --   but not handled.
146 --
147 -- Developer Implementation Notes:
148 --   Any post-processing required after the insert dml is issued should be
149 --   coded within this procedure. It is important to note that any 3rd party
150 --   maintenance should be reviewed before placing in this procedure.
151 --
152 -- Access Status:
153 --   Internal Table Handler Use Only.
154 --
155 -- {End Of Comments}
156 -- ----------------------------------------------------------------------------
157 Procedure post_insert(p_rec in per_za_lsa_shd.g_za_rec_type) is
158 --
159   l_proc  varchar2(72) := g_package||'post_insert';
160 --
161 Begin
162   hr_utility.set_location('Entering:'||l_proc, 5);
163   --
164   hr_utility.set_location(' Leaving:'||l_proc, 10);
165 End post_insert;
166 --
167 -- ----------------------------------------------------------------------------
168 -- |---------------------------------< ins >----------------------------------|
169 -- ----------------------------------------------------------------------------
170 Procedure ins
171   (
172   p_rec            in out nocopy per_za_lsa_shd.g_za_rec_type,
173   p_validate       in     boolean default false
174   ) is
175 --
176   l_proc  varchar2(72) := g_package||'ins';
177 --
178 Begin
179   hr_utility.set_location('Entering:'||l_proc, 5);
180   --
181   -- Determine if the business process is to be validated.
182   --
183   If p_validate then
184     --
185     -- Issue the savepoint.
186     --
187     SAVEPOINT ins_lsa;
188   End If;
189 
190   --
191   -- Insert the row
192   --
193   insert_dml(p_rec);
194   --
195   -- Call the supporting post-insert operation
196   --
197   post_insert(p_rec);
198   --
199   -- If we are validating then raise the Validate_Enabled exception
200   --
201   If p_validate then
202     Raise HR_Api.Validate_Enabled;
203   End If;
204   --
205   hr_utility.set_location(' Leaving:'||l_proc, 10);
206 Exception
207   When HR_Api.Validate_Enabled Then
208     --
209     -- As the Validate_Enabled exception has been raised
210     -- we must rollback to the savepoint
211     --
212     ROLLBACK TO ins_lsa;
213 end ins;
214 --
215 -- ----------------------------------------------------------------------------
216 -- |---------------------------------< ins >----------------------------------|
217 -- ----------------------------------------------------------------------------
218 Procedure ins
219    (p_agreement_id             	in number,
220     p_validate					in boolean  default FALSE,
221 	p_name						in varchar2 default null,
222 	p_description				in varchar2 default null,
223 	p_agreement_number			in varchar2 default null,
224   	p_person_id             	in number,
225 	p_agreement_start_date		in date		default null,
226 	p_agreement_end_date		in date		default null,
227 	p_status					in varchar2 default null,
228 	p_seta						in varchar2 default null,
229 	p_probationary_end_date		in date		default null,
230 	p_terminated_by				in varchar2 default null,
231 	p_learner_type				in varchar2 default null,
232 	p_reason_for_termination	in varchar2 default null,
233 	p_actual_end_date			in date		default null,
234 	p_agreement_hard_copy_id	in number 	default null) IS
235 --
236   l_rec	  	per_za_lsa_shd.g_za_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   per_za_lsa_shd.convert_args
247   (
248   	p_agreement_id,
249   	p_person_id,
250 	p_name,
251 	p_description,
252 	p_agreement_number,
253 	p_agreement_start_date,
254 	p_agreement_end_date,
255 	p_status,
256 	p_seta,
257 	p_probationary_end_date,
258 	p_terminated_by,
259 	p_learner_type,
260 	p_reason_for_termination,
261 	p_actual_end_date,
262 	p_agreement_hard_copy_id
263   );
264   --
265   -- Having converted the arguments into the ass_rec
266   -- plsql record structure we call the corresponding record business process.
267   --
268   ins(l_rec, p_validate);
269   --
270   -- As the primary key argument(s)
271   -- are specified as an OUT's we must set these values.
272   --
273   --
274   hr_utility.set_location(' Leaving:'||l_proc, 10);
275 End ins;
276 --
277 end per_za_lsa_ins;