DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_SDB_SHD

Source


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