DBA Data[Home] [Help]

PACKAGE BODY: APPS.GHR_NLA_SHD

Source


1 Package Body ghr_nla_shd as
2 /* $Header: ghnlarhi.pkb 120.1.12010000.1 2009/03/26 10:12:16 utokachi noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ghr_nla_shd.';  -- Global package name
9 --
10 --
11 -- ----------------------------------------------------------------------------
12 -- |---------------------------< constraint_error >---------------------------|
13 -- ----------------------------------------------------------------------------
14 Procedure constraint_error
15             (p_constraint_name in all_constraints.constraint_name%TYPE) Is
16 --
17   l_proc varchar2(72) ;
18 --
19 Begin
20   l_proc  := g_package||'constraint_error';
21   hr_utility.set_location('Entering:'||l_proc, 5);
22   --
23   If (p_constraint_name = 'GHR_NOAC_LAS_FK1') Then
24     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
25     hr_utility.set_message_token('PROCEDURE', l_proc);
26     hr_utility.set_message_token('STEP','5');
27     hr_utility.raise_error;
28   ElsIf (p_constraint_name = 'GHR_NOAC_LAS_PK') Then
29     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
30     hr_utility.set_message_token('PROCEDURE', l_proc);
31     hr_utility.set_message_token('STEP','10');
32     hr_utility.raise_error;
33   Else
34     hr_utility.set_message(801, 'HR_7877_API_INVALID_CONSTRAINT');
35     hr_utility.set_message_token('PROCEDURE', l_proc);
36     hr_utility.set_message_token('CONSTRAINT_NAME', p_constraint_name);
37     hr_utility.raise_error;
38   End If;
39   --
40   hr_utility.set_location(' Leaving:'||l_proc, 10);
41 End constraint_error;
42 --
43 -- ----------------------------------------------------------------------------
44 -- |-----------------------------< api_updating >-----------------------------|
45 -- ----------------------------------------------------------------------------
46 Function api_updating
47   (
48   p_noac_la_id                         in number,
49   p_object_version_number              in number
50   )      Return Boolean Is
51 --
52   --
53   -- Cursor selects the 'current' row from the HR Schema
54   --
55   Cursor C_Sel1 is
56     select
57 		noac_la_id,
58 	nature_of_action_id,
59 	lac_lookup_code,
60 	enabled_flag,
61 	date_from,
62 	date_to,
63 	object_version_number,
64 	valid_first_lac_flag,
65 	valid_second_lac_flag
66     from	ghr_noac_las
67     where	noac_la_id = p_noac_la_id;
68 --
69   l_proc varchar2(72);
70   l_fct_ret	boolean;
71 --
72 Begin
73   l_proc := g_package||'api_updating';
74   hr_utility.set_location('Entering:'||l_proc, 5);
75   --
76   If (
77 	p_noac_la_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_noac_la_id = g_old_rec.noac_la_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_noac_la_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 	noac_la_id,
137 	nature_of_action_id,
138 	lac_lookup_code,
139 	enabled_flag,
140 	date_from,
141 	date_to,
142 	object_version_number,
143 	valid_first_lac_flag,
144 	valid_second_lac_flag
145     from	ghr_noac_las
146     where	noac_la_id = p_noac_la_id
147     for	update nowait;
148 --
149   l_proc varchar2(72);
150 --
151 Begin
152   l_proc := g_package||'lck';
153   hr_utility.set_location('Entering:'||l_proc, 5);
154   --
155   -- Add any mandatory argument checking here:
156   -- Example:
157   -- hr_api.mandatory_arg_error
158   --   (p_api_name       => l_proc,
159   --    p_argument       => 'object_version_number',
160   --    p_argument_value => p_object_version_number);
161   --
162   Open  C_Sel1;
163   Fetch C_Sel1 Into g_old_rec;
164   If C_Sel1%notfound then
165     Close C_Sel1;
166     --
167     -- The primary key is invalid therefore we must error
168     --
169     hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
170     hr_utility.raise_error;
171   End If;
172   Close C_Sel1;
173   If (p_object_version_number <> g_old_rec.object_version_number) Then
174         hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
175         hr_utility.raise_error;
176       End If;
177 --
178   hr_utility.set_location(' Leaving:'||l_proc, 10);
179 --
180 -- We need to trap the ORA LOCK exception
181 --
182 Exception
183   When HR_Api.Object_Locked then
184     --
185     -- The object is locked therefore we need to supply a meaningful
186     -- error message.
187     --
188     hr_utility.set_message(801, 'HR_7165_OBJECT_LOCKED');
189     hr_utility.set_message_token('TABLE_NAME', 'ghr_noac_las');
190     hr_utility.raise_error;
191 End lck;
192 --
193 -- ----------------------------------------------------------------------------
194 -- |-----------------------------< convert_args >-----------------------------|
195 -- ----------------------------------------------------------------------------
196 Function convert_args
197 	(
198 	p_noac_la_id                    in number,
199 	p_nature_of_action_id           in number,
200 	p_lac_lookup_code               in varchar2,
201 	p_enabled_flag                  in varchar2,
202 	p_date_from                     in date,
203 	p_date_to                       in date,
204 	p_object_version_number         in number,
205 	p_valid_first_lac_flag          in varchar2,
206 	p_valid_second_lac_flag         in varchar2
207 	)
208 	Return g_rec_type is
209 --
210   l_rec	  g_rec_type;
211   l_proc  varchar2(72);
212 --
213 Begin
214   --
215   l_proc := g_package||'convert_args';
216   hr_utility.set_location('Entering:'||l_proc, 5);
217   --
218   -- Convert arguments into local l_rec structure.
219   --
220   l_rec.noac_la_id                       := p_noac_la_id;
221   l_rec.nature_of_action_id              := p_nature_of_action_id;
222   l_rec.lac_lookup_code                  := p_lac_lookup_code;
223   l_rec.enabled_flag                     := p_enabled_flag;
224   l_rec.date_from                        := p_date_from;
225   l_rec.date_to                          := p_date_to;
226   l_rec.object_version_number            := p_object_version_number;
227   l_rec.valid_first_lac_flag             := p_valid_first_lac_flag;
228   l_rec.valid_second_lac_flag            := p_valid_second_lac_flag;
229   --
230   -- Return the plsql record structure.
231   --
232   hr_utility.set_location(' Leaving:'||l_proc, 10);
233   Return(l_rec);
234 --
235 End convert_args;
236 --
237 end ghr_nla_shd;