DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_BFS_SHD

Source


1 Package Body pqh_bfs_shd as
2 /* $Header: pqbfsrhi.pkb 115.10 2003/04/02 20:01:46 srajakum ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  pqh_bfs_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_FUND_SRCS_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_FUND_SRC_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_FUND_SRC_UK') Then
33     hr_utility.set_message(8302, 'PQH_DUPLICATE_BUDGET_SRCS');
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_fund_src_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_fund_src_id,
60 	budget_element_id,
61 	cost_allocation_keyflex_id,
62         project_id,
63         award_id,
64         task_id,
65         expenditure_type,
66         organization_id,
67 	distribution_percentage,
68 	object_version_number
69     from	pqh_budget_fund_srcs
70     where	budget_fund_src_id = p_budget_fund_src_id;
71 --
72   l_proc	varchar2(72)	:= g_package||'api_updating';
73   l_fct_ret	boolean;
74 --
75 Begin
76   hr_utility.set_location('Entering:'||l_proc, 5);
77   --
78   If (
79 	p_budget_fund_src_id is null and
80 	p_object_version_number is null
81      ) Then
82     --
83     -- One of the primary key arguments is null therefore we must
84     -- set the returning function value to false
85     --
86     l_fct_ret := false;
87   Else
88     If (
89 	p_budget_fund_src_id = g_old_rec.budget_fund_src_id and
90 	p_object_version_number = g_old_rec.object_version_number
91        ) Then
92       hr_utility.set_location(l_proc, 10);
93       --
94       -- The g_old_rec is current therefore we must
95       -- set the returning function to true
96       --
97       l_fct_ret := true;
98     Else
99       --
100       -- Select the current row into g_old_rec
101       --
102       Open C_Sel1;
103       Fetch C_Sel1 Into g_old_rec;
104       If C_Sel1%notfound Then
105         Close C_Sel1;
106         --
107         -- The primary key is invalid therefore we must error
108         --
109         hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
110         hr_utility.raise_error;
111       End If;
112       Close C_Sel1;
113       If (p_object_version_number <> g_old_rec.object_version_number) Then
114         hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
115         hr_utility.raise_error;
116       End If;
117       hr_utility.set_location(l_proc, 15);
118       l_fct_ret := true;
119     End If;
120   End If;
121   hr_utility.set_location(' Leaving:'||l_proc, 20);
122   Return (l_fct_ret);
123 --
124 End api_updating;
125 --
126 -- ----------------------------------------------------------------------------
127 -- |---------------------------------< lck >----------------------------------|
128 -- ----------------------------------------------------------------------------
129 Procedure lck
130   (
131   p_budget_fund_src_id                 in number,
132   p_object_version_number              in number
133   ) is
134 --
135 -- Cursor selects the 'current' row from the HR Schema
136 --
137   Cursor C_Sel1 is
138     select 	budget_fund_src_id,
139 	budget_element_id,
140 	cost_allocation_keyflex_id,
141         project_id,
142         award_id,
143         task_id,
144         expenditure_type,
145         organization_id,
146 	distribution_percentage,
147 	object_version_number
148     from	pqh_budget_fund_srcs
149     where	budget_fund_src_id = p_budget_fund_src_id
150     for	update nowait;
151 --
152   l_proc	varchar2(72) := g_package||'lck';
153 --
154 Begin
155   hr_utility.set_location('Entering:'||l_proc, 5);
156   --
157   -- Add any mandatory argument checking here:
158   -- Example:
159   -- hr_api.mandatory_arg_error
160   --   (p_api_name       => l_proc,
161   --    p_argument       => 'object_version_number',
162   --    p_argument_value => p_object_version_number);
163   --
164   Open  C_Sel1;
165   Fetch C_Sel1 Into g_old_rec;
166   If C_Sel1%notfound then
167     Close C_Sel1;
168     --
169     -- The primary key is invalid therefore we must error
170     --
171     hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
172     hr_utility.raise_error;
173   End If;
174   Close C_Sel1;
175   If (p_object_version_number <> g_old_rec.object_version_number) Then
176         hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
177         hr_utility.raise_error;
178       End If;
179 --
180   hr_utility.set_location(' Leaving:'||l_proc, 10);
181 --
182 -- We need to trap the ORA LOCK exception
183 --
184 Exception
185   When HR_Api.Object_Locked then
186     --
187     -- The object is locked therefore we need to supply a meaningful
188     -- error message.
189     --
190     hr_utility.set_message(801, 'HR_7165_OBJECT_LOCKED');
191     hr_utility.set_message_token('TABLE_NAME', 'pqh_budget_fund_srcs');
192     hr_utility.raise_error;
193 End lck;
194 --
195 -- ----------------------------------------------------------------------------
196 -- |-----------------------------< convert_args >-----------------------------|
197 -- ----------------------------------------------------------------------------
198 Function convert_args
199 	(
200 	p_budget_fund_src_id            in number,
201 	p_budget_element_id             in number,
202 	p_cost_allocation_keyflex_id    in number,
203         p_project_id                    in number,
204         p_award_id                      in number,
205         p_task_id                       in number,
206         p_expenditure_type              in varchar2,
207         p_organization_id               in number,
208 	p_distribution_percentage       in number,
209 	p_object_version_number         in number
210 	)
211 	Return g_rec_type is
212 --
213   l_rec	  g_rec_type;
214   l_proc  varchar2(72) := g_package||'convert_args';
215 --
216 Begin
217   --
218   hr_utility.set_location('Entering:'||l_proc, 5);
219   --
220   -- Convert arguments into local l_rec structure.
221   --
222   l_rec.budget_fund_src_id               := p_budget_fund_src_id;
223   l_rec.budget_element_id                := p_budget_element_id;
224   l_rec.cost_allocation_keyflex_id       := p_cost_allocation_keyflex_id;
225   l_rec.project_id                       := p_project_id;
226   l_rec.award_id                         := p_award_id;
227   l_rec.task_id                          := p_task_id;
228   l_rec.expenditure_type                 := p_expenditure_type;
229   l_rec.organization_id                  := p_organization_id;
230   l_rec.distribution_percentage          := p_distribution_percentage;
231   l_rec.object_version_number            := p_object_version_number;
232   --
233   -- Return the plsql record structure.
234   --
235   hr_utility.set_location(' Leaving:'||l_proc, 10);
236   Return(l_rec);
237 --
238 End convert_args;
239 --
240 end pqh_bfs_shd;