DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_RTM_SHD

Source


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