[Home] [Help]
PACKAGE BODY: APPS.PQH_BPR_SHD
Source
1 Package Body pqh_bpr_shd as
2 /* $Header: pqbprrhi.pkb 115.8 2002/12/05 19:29:59 rpasapul ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' pqh_bpr_shd.'; -- Global package name
9 --
10 --
11 -- ----------------------------------------------------------------------------
12 -- |---------------------------< constraint_error >---------------------------|
13 -- ----------------------------------------------------------------------------
14 Procedure constraint_error
15 (p_constraint_name in all_constraints.constraint_name%TYPE) Is
16 --
17 l_proc varchar2(72) := g_package||'constraint_error';
18 --
19 Begin
20 hr_utility.set_location('Entering:'||l_proc, 5);
21 --
22 If (p_constraint_name = 'PQH_BUDGET_PERIODS_FK1') Then
23 hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
24 hr_utility.set_message_token('PROCEDURE', l_proc);
25 hr_utility.set_message_token('STEP','5');
26 hr_utility.raise_error;
27 ElsIf (p_constraint_name = 'PQH_BUDGET_SETS_FK2') Then
28 hr_utility.set_message(8302, 'PQH_BUDGET_SETS_EXISTS');
29 hr_utility.raise_error;
30 ElsIf (p_constraint_name = 'PQH_BUDGET_PERIODS_FK2') Then
31 hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
32 hr_utility.set_message_token('PROCEDURE', l_proc);
33 hr_utility.set_message_token('STEP','10');
34 hr_utility.raise_error;
35 ElsIf (p_constraint_name = 'PQH_BUDGET_PERIODS_FK3') Then
36 hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
37 hr_utility.set_message_token('PROCEDURE', l_proc);
38 hr_utility.set_message_token('STEP','15');
39 hr_utility.raise_error;
40 ElsIf (p_constraint_name = 'PQH_BUDGET_PERIODS_PK') Then
41 hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
42 hr_utility.set_message_token('PROCEDURE', l_proc);
43 hr_utility.set_message_token('STEP','20');
44 hr_utility.raise_error;
45 ElsIf (p_constraint_name = 'PQH_BUDGET_PERIODS_UK') Then
46 --
47 -- Code Changed to provide a more meaningful message on
48 -- unique constraint failure.
49 --
50 hr_utility.set_message(8302,'PQH_WKS_DUPLICATE_PERIOD');
51 hr_utility.raise_error;
52 Else
53 hr_utility.set_message(801, 'HR_7877_API_INVALID_CONSTRAINT');
54 hr_utility.set_message_token('PROCEDURE', l_proc);
55 hr_utility.set_message_token('CONSTRAINT_NAME', p_constraint_name);
56 hr_utility.raise_error;
57 End If;
58 --
59 hr_utility.set_location(' Leaving:'||l_proc, 10);
60 End constraint_error;
61 --
62 -- ----------------------------------------------------------------------------
63 -- |-----------------------------< api_updating >-----------------------------|
64 -- ----------------------------------------------------------------------------
65 Function api_updating
66 (
67 p_budget_period_id in number,
68 p_object_version_number in number
69 ) Return Boolean Is
70 --
71 --
72 -- Cursor selects the 'current' row from the HR Schema
73 --
74 Cursor C_Sel1 is
75 select
76 budget_period_id,
77 budget_detail_id,
78 start_time_period_id,
79 end_time_period_id,
80 budget_unit1_percent,
81 budget_unit2_percent,
82 budget_unit3_percent,
83 budget_unit1_value,
84 budget_unit2_value,
85 budget_unit3_value,
86 budget_unit1_value_type_cd,
87 budget_unit2_value_type_cd,
88 budget_unit3_value_type_cd,
89 budget_unit1_available,
90 budget_unit2_available,
91 budget_unit3_available,
92 object_version_number
93 from pqh_budget_periods
94 where budget_period_id = p_budget_period_id;
95 --
96 l_proc varchar2(72) := g_package||'api_updating';
97 l_fct_ret boolean;
98 --
99 Begin
100 hr_utility.set_location('Entering:'||l_proc, 5);
101 --
102 If (
103 p_budget_period_id is null and
104 p_object_version_number is null
105 ) Then
106 --
107 -- One of the primary key arguments is null therefore we must
108 -- set the returning function value to false
109 --
110 l_fct_ret := false;
111 Else
112 If (
113 p_budget_period_id = g_old_rec.budget_period_id and
114 p_object_version_number = g_old_rec.object_version_number
115 ) Then
116 hr_utility.set_location(l_proc, 10);
117 --
118 -- The g_old_rec is current therefore we must
119 -- set the returning function to true
120 --
121 l_fct_ret := true;
122 Else
123 --
124 -- Select the current row into g_old_rec
125 --
126 Open C_Sel1;
127 Fetch C_Sel1 Into g_old_rec;
128 If C_Sel1%notfound Then
129 Close C_Sel1;
130 --
131 -- The primary key is invalid therefore we must error
132 --
133 hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
134 hr_utility.raise_error;
135 End If;
136 Close C_Sel1;
137 If (p_object_version_number <> g_old_rec.object_version_number) Then
138 hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
139 hr_utility.raise_error;
140 End If;
141 hr_utility.set_location(l_proc, 15);
142 l_fct_ret := true;
143 End If;
144 End If;
145 hr_utility.set_location(' Leaving:'||l_proc, 20);
146 Return (l_fct_ret);
147 --
148 End api_updating;
149 --
150 -- ----------------------------------------------------------------------------
151 -- |---------------------------------< lck >----------------------------------|
152 -- ----------------------------------------------------------------------------
153 Procedure lck
154 (
155 p_budget_period_id in number,
156 p_object_version_number in number
157 ) is
158 --
159 -- Cursor selects the 'current' row from the HR Schema
160 --
161 Cursor C_Sel1 is
162 select budget_period_id,
163 budget_detail_id,
164 start_time_period_id,
165 end_time_period_id,
166 budget_unit1_percent,
167 budget_unit2_percent,
168 budget_unit3_percent,
169 budget_unit1_value,
170 budget_unit2_value,
171 budget_unit3_value,
172 budget_unit1_value_type_cd,
173 budget_unit2_value_type_cd,
174 budget_unit3_value_type_cd,
175 budget_unit1_available,
176 budget_unit2_available,
177 budget_unit3_available,
178 object_version_number
179 from pqh_budget_periods
180 where budget_period_id = p_budget_period_id
181 for update nowait;
182 --
183 l_proc varchar2(72) := g_package||'lck';
184 --
185 Begin
186 hr_utility.set_location('Entering:'||l_proc, 5);
187 --
188 -- Add any mandatory argument checking here:
189 -- Example:
190 -- hr_api.mandatory_arg_error
191 -- (p_api_name => l_proc,
192 -- p_argument => 'object_version_number',
193 -- p_argument_value => p_object_version_number);
194 --
195 Open C_Sel1;
196 Fetch C_Sel1 Into g_old_rec;
197 If C_Sel1%notfound then
198 Close C_Sel1;
199 --
200 -- The primary key is invalid therefore we must error
201 --
202 hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
203 hr_utility.raise_error;
204 End If;
205 Close C_Sel1;
206 If (p_object_version_number <> g_old_rec.object_version_number) Then
207 hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
208 hr_utility.raise_error;
209 End If;
210 --
211 hr_utility.set_location(' Leaving:'||l_proc, 10);
212 --
213 -- We need to trap the ORA LOCK exception
214 --
215 Exception
216 When HR_Api.Object_Locked then
217 --
218 -- The object is locked therefore we need to supply a meaningful
219 -- error message.
220 --
221 hr_utility.set_message(801, 'HR_7165_OBJECT_LOCKED');
222 hr_utility.set_message_token('TABLE_NAME', 'pqh_budget_periods');
223 hr_utility.raise_error;
224 End lck;
225 --
226 -- ----------------------------------------------------------------------------
227 -- |-----------------------------< convert_args >-----------------------------|
228 -- ----------------------------------------------------------------------------
229 Function convert_args
230 (
231 p_budget_period_id in number,
232 p_budget_detail_id in number,
233 p_start_time_period_id in number,
234 p_end_time_period_id in number,
235 p_budget_unit1_percent in number,
236 p_budget_unit2_percent in number,
237 p_budget_unit3_percent in number,
238 p_budget_unit1_value in number,
239 p_budget_unit2_value in number,
240 p_budget_unit3_value in number,
241 p_budget_unit1_value_type_cd in varchar2,
242 p_budget_unit2_value_type_cd in varchar2,
243 p_budget_unit3_value_type_cd in varchar2,
244 p_budget_unit1_available in number,
245 p_budget_unit2_available in number,
246 p_budget_unit3_available in number,
247 p_object_version_number in number
248 )
249 Return g_rec_type is
250 --
251 l_rec g_rec_type;
252 l_proc varchar2(72) := g_package||'convert_args';
253 --
254 Begin
255 --
256 hr_utility.set_location('Entering:'||l_proc, 5);
257 --
258 -- Convert arguments into local l_rec structure.
259 --
260 l_rec.budget_period_id := p_budget_period_id;
261 l_rec.budget_detail_id := p_budget_detail_id;
262 l_rec.start_time_period_id := p_start_time_period_id;
263 l_rec.end_time_period_id := p_end_time_period_id;
264 l_rec.budget_unit1_percent := p_budget_unit1_percent;
265 l_rec.budget_unit2_percent := p_budget_unit2_percent;
266 l_rec.budget_unit3_percent := p_budget_unit3_percent;
267 l_rec.budget_unit1_value := p_budget_unit1_value;
268 l_rec.budget_unit2_value := p_budget_unit2_value;
269 l_rec.budget_unit3_value := p_budget_unit3_value;
273 l_rec.budget_unit1_available := p_budget_unit1_available;
270 l_rec.budget_unit1_value_type_cd := p_budget_unit1_value_type_cd;
271 l_rec.budget_unit2_value_type_cd := p_budget_unit2_value_type_cd;
272 l_rec.budget_unit3_value_type_cd := p_budget_unit3_value_type_cd;
274 l_rec.budget_unit2_available := p_budget_unit2_available;
275 l_rec.budget_unit3_available := p_budget_unit3_available;
276 l_rec.object_version_number := p_object_version_number;
277 --
278 -- Return the plsql record structure.
279 --
280 hr_utility.set_location(' Leaving:'||l_proc, 10);
281 Return(l_rec);
282 --
283 End convert_args;
284 --
285 end pqh_bpr_shd;