DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_RAN_SHD

Source


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