[Home] [Help]
PACKAGE BODY: APPS.PQH_BEL_SHD
Source
1 Package Body pqh_bel_shd as
2 /* $Header: pqbelrhi.pkb 115.6 2002/12/05 16:33:15 rpasapul ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' pqh_bel_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_ELEMENTS_FK2') 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_ELEMENT_PK') Then
28 hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
29 hr_utility.set_message_token('PROCEDURE', l_proc);
30 hr_utility.set_message_token('STEP','10');
31 hr_utility.raise_error;
32 ElsIf (p_constraint_name = 'PQH_BUDGET_ELEMENT_UK') Then
33 hr_utility.set_message(8302, 'PQH_DUPLICATE_BUDGET_ELEMENTS');
34 hr_utility.raise_error;
35 Else
36 hr_utility.set_message(801, 'HR_7877_API_INVALID_CONSTRAINT');
37 hr_utility.set_message_token('PROCEDURE', l_proc);
38 hr_utility.set_message_token('CONSTRAINT_NAME', p_constraint_name);
39 hr_utility.raise_error;
40 End If;
41 --
42 hr_utility.set_location(' Leaving:'||l_proc, 10);
43 End constraint_error;
44 --
45 -- ----------------------------------------------------------------------------
46 -- |-----------------------------< api_updating >-----------------------------|
47 -- ----------------------------------------------------------------------------
48 Function api_updating
49 (
50 p_budget_element_id in number,
51 p_object_version_number in number
52 ) Return Boolean Is
53 --
54 --
55 -- Cursor selects the 'current' row from the HR Schema
56 --
57 Cursor C_Sel1 is
58 select
59 budget_element_id,
60 budget_set_id,
61 element_type_id,
62 distribution_percentage,
63 object_version_number
64 from pqh_budget_elements
65 where budget_element_id = p_budget_element_id;
66 --
67 l_proc varchar2(72) := g_package||'api_updating';
68 l_fct_ret boolean;
69 --
70 Begin
71 hr_utility.set_location('Entering:'||l_proc, 5);
72 --
73 If (
74 p_budget_element_id is null and
75 p_object_version_number is null
76 ) Then
77 --
78 -- One of the primary key arguments is null therefore we must
79 -- set the returning function value to false
80 --
81 l_fct_ret := false;
82 Else
83 If (
84 p_budget_element_id = g_old_rec.budget_element_id and
85 p_object_version_number = g_old_rec.object_version_number
86 ) Then
87 hr_utility.set_location(l_proc, 10);
88 --
89 -- The g_old_rec is current therefore we must
90 -- set the returning function to true
91 --
92 l_fct_ret := true;
93 Else
94 --
95 -- Select the current row into g_old_rec
96 --
97 Open C_Sel1;
98 Fetch C_Sel1 Into g_old_rec;
99 If C_Sel1%notfound Then
100 Close C_Sel1;
101 --
102 -- The primary key is invalid therefore we must error
103 --
104 hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
105 hr_utility.raise_error;
106 End If;
107 Close C_Sel1;
108 If (p_object_version_number <> g_old_rec.object_version_number) Then
109 hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
110 hr_utility.raise_error;
111 End If;
112 hr_utility.set_location(l_proc, 15);
113 l_fct_ret := true;
114 End If;
115 End If;
116 hr_utility.set_location(' Leaving:'||l_proc, 20);
117 Return (l_fct_ret);
118 --
119 End api_updating;
120 --
121 -- ----------------------------------------------------------------------------
122 -- |---------------------------------< lck >----------------------------------|
123 -- ----------------------------------------------------------------------------
124 Procedure lck
125 (
126 p_budget_element_id in number,
127 p_object_version_number in number
128 ) is
129 --
130 -- Cursor selects the 'current' row from the HR Schema
131 --
132 Cursor C_Sel1 is
133 select budget_element_id,
134 budget_set_id,
135 element_type_id,
136 distribution_percentage,
137 object_version_number
138 from pqh_budget_elements
139 where budget_element_id = p_budget_element_id
140 for update nowait;
141 --
142 l_proc varchar2(72) := g_package||'lck';
143 --
144 Begin
145 hr_utility.set_location('Entering:'||l_proc, 5);
146 --
147 -- Add any mandatory argument checking here:
148 -- Example:
149 -- hr_api.mandatory_arg_error
150 -- (p_api_name => l_proc,
151 -- p_argument => 'object_version_number',
152 -- p_argument_value => p_object_version_number);
153 --
154 Open C_Sel1;
155 Fetch C_Sel1 Into g_old_rec;
156 If C_Sel1%notfound then
157 Close C_Sel1;
158 --
159 -- The primary key is invalid therefore we must error
160 --
161 hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
162 hr_utility.raise_error;
163 End If;
164 Close C_Sel1;
165 If (p_object_version_number <> g_old_rec.object_version_number) Then
166 hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
167 hr_utility.raise_error;
168 End If;
169 --
170 hr_utility.set_location(' Leaving:'||l_proc, 10);
171 --
172 -- We need to trap the ORA LOCK exception
173 --
174 Exception
175 When HR_Api.Object_Locked then
176 --
177 -- The object is locked therefore we need to supply a meaningful
178 -- error message.
179 --
180 hr_utility.set_message(801, 'HR_7165_OBJECT_LOCKED');
181 hr_utility.set_message_token('TABLE_NAME', 'pqh_budget_elements');
182 hr_utility.raise_error;
183 End lck;
184 --
185 -- ----------------------------------------------------------------------------
186 -- |-----------------------------< convert_args >-----------------------------|
187 -- ----------------------------------------------------------------------------
188 Function convert_args
189 (
190 p_budget_element_id in number,
191 p_budget_set_id in number,
192 p_element_type_id in number,
193 p_distribution_percentage in number,
194 p_object_version_number in number
195 )
196 Return g_rec_type is
197 --
198 l_rec g_rec_type;
199 l_proc varchar2(72) := g_package||'convert_args';
200 --
201 Begin
202 --
203 hr_utility.set_location('Entering:'||l_proc, 5);
204 --
205 -- Convert arguments into local l_rec structure.
206 --
207 l_rec.budget_element_id := p_budget_element_id;
208 l_rec.budget_set_id := p_budget_set_id;
209 l_rec.element_type_id := p_element_type_id;
210 l_rec.distribution_percentage := p_distribution_percentage;
211 l_rec.object_version_number := p_object_version_number;
212 --
213 -- Return the plsql record structure.
214 --
215 hr_utility.set_location(' Leaving:'||l_proc, 10);
216 Return(l_rec);
217 --
218 End convert_args;
219 --
220 end pqh_bel_shd;