DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_RCT_SHD

Source


1 Package Body pqh_rct_shd as
2 /* $Header: pqrctrhi.pkb 115.24 2004/02/19 13:29:18 srajakum noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  pqh_rct_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 = 'PQH_ROUTING_CATEGORIES_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 = 'PQH_ROUTING_CATEGORIES_FK2') 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 = 'PQH_ROUTING_CATEGORIES_FK3') 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     --
37   ElsIf (p_constraint_name = 'PQH_ROUTING_CATEGORIES_FK4') Then
38     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
39     hr_utility.set_message_token('PROCEDURE', l_proc);
40     hr_utility.set_message_token('STEP','20');
41     hr_utility.raise_error;
42   ElsIf (p_constraint_name = 'PQH_ROUTING_CATEGORIES_FK5') Then
43     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
44     hr_utility.set_message_token('PROCEDURE', l_proc);
45     hr_utility.set_message_token('STEP','25');
46     hr_utility.raise_error;
47   ElsIf (p_constraint_name = 'PQH_ROUTING_CATEGORIES_PK') Then
48     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
49     hr_utility.set_message_token('PROCEDURE', l_proc);
50     hr_utility.set_message_token('STEP','30');
51     hr_utility.raise_error;
52   ElsIf (p_constraint_name = 'PQH_ROUTING_HISTORY_FK1') Then
53     hr_utility.set_message(8302, 'PQH_NO_DEL_RCT_IF_HIST_EXIST');
54     hr_utility.raise_error;
55   ElsIf (p_constraint_name = 'PQH_ROUTING_CATEGORIES_UK1') Then
56     hr_utility.set_message(8302, 'PQH_DUPLICATE_LIST_NAME');
57     hr_utility.raise_error;
58   Else
59     hr_utility.set_message(801, 'HR_7877_API_INVALID_CONSTRAINT');
60     hr_utility.set_message_token('PROCEDURE', l_proc);
61     hr_utility.set_message_token('CONSTRAINT_NAME', p_constraint_name);
62     hr_utility.raise_error;
63   End If;
64   --
65   hr_utility.set_location(' Leaving:'||l_proc, 10);
66 End constraint_error;
67 --
68 -- ----------------------------------------------------------------------------
69 -- |-----------------------------< api_updating >-----------------------------|
70 -- ----------------------------------------------------------------------------
71 Function api_updating
72   (
73   p_routing_category_id                in number,
74   p_object_version_number              in number
75   )      Return Boolean Is
76 --
77   --
78   -- Cursor selects the 'current' row from the HR Schema
79   --
80   Cursor C_Sel1 is
81     select
82 	routing_category_id,
83 	transaction_category_id,
84         enable_flag,
85         default_flag,
86         delete_flag,
87 	routing_list_id,
88 	position_structure_id,
89 	override_position_id,
90 	override_assignment_id,
91 	override_role_id,
92         override_user_id,
93 	object_version_number
94     from	pqh_routing_categories
95     where	routing_category_id = p_routing_category_id;
96 --
97   l_proc	varchar2(72)	:= g_package||'api_updating';
98   l_fct_ret	boolean;
99 --
100 Begin
101   hr_utility.set_location('Entering:'||l_proc, 5);
102   --
103   If (
104 	p_routing_category_id is null and
105 	p_object_version_number is null
106      ) Then
107     --
108     -- One of the primary key arguments is null therefore we must
109     -- set the returning function value to false
110     --
111     l_fct_ret := false;
112   Else
113     If (
114 	p_routing_category_id = g_old_rec.routing_category_id and
115 	p_object_version_number = g_old_rec.object_version_number
116        ) Then
117       hr_utility.set_location(l_proc, 10);
118       --
119       -- The g_old_rec is current therefore we must
120       -- set the returning function to true
121       --
122       l_fct_ret := true;
123     Else
124       --
125       -- Select the current row into g_old_rec
126       --
127       Open C_Sel1;
128       Fetch C_Sel1 Into g_old_rec;
129       If C_Sel1%notfound Then
130         Close C_Sel1;
131         --
132         -- The primary key is invalid therefore we must error
133         --
134         hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
135         hr_utility.raise_error;
136       End If;
137       Close C_Sel1;
138       If (p_object_version_number <> g_old_rec.object_version_number) Then
139         hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
140         hr_utility.raise_error;
141       End If;
142       hr_utility.set_location(l_proc, 15);
143       l_fct_ret := true;
144     End If;
145   End If;
146   hr_utility.set_location(' Leaving:'||l_proc, 20);
147   Return (l_fct_ret);
148 --
149 End api_updating;
150 --
151 -- ----------------------------------------------------------------------------
152 -- |---------------------------------< lck >----------------------------------|
153 -- ----------------------------------------------------------------------------
154 Procedure lck
155   (
156   p_routing_category_id                in number,
157   p_object_version_number              in number
158   ) is
159 --
160 -- Cursor selects the 'current' row from the HR Schema
161 --
162   Cursor C_Sel1 is
163     select 	routing_category_id,
164 	transaction_category_id,
165         enable_flag,
166         default_flag,
167         delete_flag,
168 	routing_list_id,
169 	position_structure_id,
170 	override_position_id,
171 	override_assignment_id,
172 	override_role_id,
173 	override_user_id,
174 	object_version_number
175     from	pqh_routing_categories
176     where	routing_category_id = p_routing_category_id
177     for	update nowait;
178 --
179   l_proc	varchar2(72) := g_package||'lck';
180 --
181 Begin
182   hr_utility.set_location('Entering:'||l_proc, 5);
183   --
184   -- Add any mandatory argument checking here:
185   -- Example:
186   -- hr_api.mandatory_arg_error
187   --   (p_api_name       => l_proc,
188   --    p_argument       => 'object_version_number',
189   --    p_argument_value => p_object_version_number);
190   --
191   Open  C_Sel1;
192   Fetch C_Sel1 Into g_old_rec;
193   If C_Sel1%notfound then
194     Close C_Sel1;
195     --
196     -- The primary key is invalid therefore we must error
197     --
198     hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
199     hr_utility.raise_error;
200   End If;
201   Close C_Sel1;
202   If (p_object_version_number <> g_old_rec.object_version_number) Then
203         hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
204         hr_utility.raise_error;
205       End If;
206 --
207   hr_utility.set_location(' Leaving:'||l_proc, 10);
208 --
209 -- We need to trap the ORA LOCK exception
210 --
211 Exception
212   When HR_Api.Object_Locked then
213     --
214     -- The object is locked therefore we need to supply a meaningful
215     -- error message.
216     --
217     hr_utility.set_message(801, 'HR_7165_OBJECT_LOCKED');
218     hr_utility.set_message_token('TABLE_NAME', 'pqh_routing_categories');
219     hr_utility.raise_error;
220 End lck;
221 --
222 -- ----------------------------------------------------------------------------
223 -- |-----------------------------< convert_args >-----------------------------|
224 -- ----------------------------------------------------------------------------
225 Function convert_args
226 	(
227 	p_routing_category_id           in number,
228 	p_transaction_category_id       in number,
229         p_enable_flag                   in varchar2,
230         p_default_flag                   in varchar2,
231         p_delete_flag                    in varchar2,
232 	p_routing_list_id               in number,
233 	p_position_structure_id         in number,
234 	p_override_position_id          in number,
235 	p_override_assignment_id        in number,
236 	p_override_role_id            in number,
237 	p_override_user_id            in number,
238 	p_object_version_number         in number
239 	)
240 	Return g_rec_type is
241 --
242   l_rec	  g_rec_type;
243   l_proc  varchar2(72) := g_package||'convert_args';
244 --
245 Begin
246   --
247   hr_utility.set_location('Entering:'||l_proc, 5);
248   --
249   -- Convert arguments into local l_rec structure.
250   --
251   l_rec.routing_category_id              := p_routing_category_id;
252   l_rec.transaction_category_id          := p_transaction_category_id;
253   l_rec.enable_flag                  := p_enable_flag;
254   l_rec.default_flag                  := p_default_flag;
255   l_rec.delete_flag                   := p_delete_flag ;
256   l_rec.routing_list_id                  := p_routing_list_id;
257   l_rec.position_structure_id            := p_position_structure_id;
258   l_rec.override_position_id             := p_override_position_id;
259   l_rec.override_assignment_id           := p_override_assignment_id;
260   l_rec.override_role_id               := p_override_role_id;
261   l_rec.override_user_id               := p_override_user_id;
262   l_rec.object_version_number            := p_object_version_number;
263   --
264   -- Return the plsql record structure.
265   --
266   hr_utility.set_location(' Leaving:'||l_proc, 10);
267   Return(l_rec);
268 --
269 End convert_args;
270 --
271 end pqh_rct_shd;