DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_TCO_SHD

Source


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