DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_ATT_BUS

Source


1 Package Body pqh_att_bus as
2 /* $Header: pqattrhi.pkb 120.3.12000000.2 2007/04/19 12:37:00 brsinha noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  pqh_att_bus.';  -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |------< chk_attribute_id >------|
12 -- ----------------------------------------------------------------------------
13 --
14 -- Description
15 --   This procedure is used to check that the primary key for the table
16 --   is created properly. It should be null on insert and
17 --   should not be able to be updated.
18 --
19 -- Pre Conditions
20 --   None.
21 --
22 -- In Parameters
23 --   attribute_id PK of record being inserted or updated.
24 --   object_version_number Object version number of record being
25 --                         inserted or updated.
26 --
27 -- Post Success
28 --   Processing continues
29 --
30 -- Post Failure
31 --   Errors handled by the procedure
32 --
33 -- Access Status
34 --   Internal table handler use only.
35 --
36 Procedure chk_attribute_id(p_attribute_id                in number,
37                            p_object_version_number       in number) is
38   --
39   l_proc         varchar2(72) := g_package||'chk_attribute_id';
40   l_api_updating boolean;
41   --
42 Begin
43   --
44   hr_utility.set_location('Entering:'||l_proc, 5);
45   --
46   l_api_updating := pqh_att_shd.api_updating
47     (p_attribute_id                => p_attribute_id,
48      p_object_version_number       => p_object_version_number);
49   --
50   if (l_api_updating
51      and nvl(p_attribute_id,hr_api.g_number)
52      <>  pqh_att_shd.g_old_rec.attribute_id) then
53     --
54     -- raise error as PK has changed
55     --
56     pqh_att_shd.constraint_error('PQH_ATTRIBUTES_PK');
57     --
58   elsif not l_api_updating then
59     --
60     -- check if PK is null
61     --
62     if p_attribute_id is not null then
63       --
64       -- raise error as PK is not null
65       --
66       pqh_att_shd.constraint_error('PQH_ATTRIBUTES_PK');
67       --
68     end if;
69     --
70   end if;
71   --
72   hr_utility.set_location('Leaving:'||l_proc, 10);
73   --
74 End chk_attribute_id;
75 --
76 -- ----------------------------------------------------------------------------
77 -- |------< chk_master_attribute_id >------|
78 -- ----------------------------------------------------------------------------
79 --
80 -- Description
81 --   This procedure checks that a referenced foreign key actually exists
82 --   in the referenced table.
83 --
84 -- Pre-Conditions
85 --   None.
86 --
87 -- In Parameters
88 --   p_attribute_id PK
89 --   p_master_attribute_id ID of FK column
90 --   p_object_version_number object version number
91 --
92 -- Post Success
93 --   Processing continues
94 --
95 -- Post Failure
96 --   Error raised.
97 --
98 -- Access Status
99 --   Internal table handler use only.
100 --
101 Procedure chk_master_attribute_id (p_attribute_id          in number,
102                             p_master_attribute_id          in number,
103                             p_object_version_number in number) is
104   --
105   l_proc         varchar2(72) := g_package||'chk_master_attribute_id';
106   l_api_updating boolean;
107   l_dummy        varchar2(1);
108   --
109   cursor c1 is
110     select null
111     from   pqh_attributes a
112     where  a.attribute_id = p_master_attribute_id;
113   --
114 Begin
115   --
116   hr_utility.set_location('Entering:'||l_proc,5);
117   --
118   l_api_updating := pqh_att_shd.api_updating
119      (p_attribute_id            => p_attribute_id,
120       p_object_version_number   => p_object_version_number);
121   --
122   if (l_api_updating
123      and nvl(p_master_attribute_id,hr_api.g_number)
124      <> nvl(pqh_att_shd.g_old_rec.master_attribute_id,hr_api.g_number)
125      or not l_api_updating) and
126      p_master_attribute_id is not null then
127     --
128     -- check if master_attribute_id value exists in pqh_attributes table
129     --
130     open c1;
131       --
132       fetch c1 into l_dummy;
133       if c1%notfound then
134         --
135         close c1;
136         --
137         -- raise error as FK does not relate to PK in pqh_attributes
138         -- table.
139         --
140         pqh_att_shd.constraint_error('PQH_ATTRIBUTES_FK2');
141         --
142       end if;
143       --
144     close c1;
145     --
146   end if;
147   --
148   hr_utility.set_location('Leaving:'||l_proc,10);
149   --
150 End chk_master_attribute_id;
151 --
152 -- ----------------------------------------------------------------------------
153 -- |------< chk_enable_flag >------|
154 -- ----------------------------------------------------------------------------
155 --
156 -- Description
157 --   This procedure is used to check that the lookup value is valid.
158 --
159 -- Pre Conditions
160 --   None.
161 --
162 -- In Parameters
163 --   attribute_id PK of record being inserted or updated.
164 --   enable_flag Value of lookup code.
165 --   effective_date effective date
166 --   object_version_number Object version number of record being
167 --                         inserted or updated.
168 --
169 -- Post Success
170 --   Processing continues
171 --
172 -- Post Failure
173 --   Error handled by procedure
174 --
175 -- Access Status
176 --   Internal table handler use only.
177 --
178 Procedure chk_enable_flag(p_attribute_id                in number,
179                             p_enable_flag               in varchar2,
180                             p_effective_date              in date,
181                             p_object_version_number       in number) is
182   --
183   l_proc         varchar2(72) := g_package||'chk_enable_flag';
184   l_api_updating boolean;
185   --
186 Begin
187   --
188   hr_utility.set_location('Entering:'||l_proc, 5);
189   --
190   l_api_updating := pqh_att_shd.api_updating
191     (p_attribute_id                => p_attribute_id,
192      p_object_version_number       => p_object_version_number);
193   --
194   if (l_api_updating
195       and p_enable_flag
196       <> nvl(pqh_att_shd.g_old_rec.enable_flag,hr_api.g_varchar2)
197       or not l_api_updating)
198       and p_enable_flag is not null then
199     --
200     -- check if value of lookup falls within lookup type.
201     --
202     if hr_api.not_exists_in_hr_lookups
203           (p_lookup_type    => 'YES_NO',
204            p_lookup_code    => p_enable_flag,
205            p_effective_date => p_effective_date) then
206       --
207       -- raise error as does not exist as lookup
208       --
209       hr_utility.set_message(801,'HR_LOOKUP_DOES_NOT_EXIST');
210       hr_utility.raise_error;
211       --
212     end if;
213     --
214   end if;
215   --
216   hr_utility.set_location('Leaving:'||l_proc,10);
217   --
218 end chk_enable_flag;
219 --
220 -- ----------------------------------------------------------------------------
221 -- |---------------------------< insert_validate >----------------------------|
222 -- ----------------------------------------------------------------------------
223 Procedure insert_validate(p_rec in pqh_att_shd.g_rec_type
224                          ,p_effective_date in date) is
225 --
226   l_proc  varchar2(72) := g_package||'insert_validate';
227 --
228 Begin
229   hr_utility.set_location('Entering:'||l_proc, 5);
230   --
231   -- Call all supporting business operations
232   --
233   chk_attribute_id
234   (p_attribute_id          => p_rec.attribute_id,
235    p_object_version_number => p_rec.object_version_number);
236   --
237   chk_master_attribute_id
238   (p_attribute_id          => p_rec.attribute_id,
239    p_master_attribute_id          => p_rec.master_attribute_id,
240    p_object_version_number => p_rec.object_version_number);
241   --
242   chk_enable_flag
243   (p_attribute_id          => p_rec.attribute_id,
244    p_enable_flag         => p_rec.enable_flag,
245    p_effective_date        => p_effective_date,
246    p_object_version_number => p_rec.object_version_number);
247   --
248   --
249   --
250   hr_utility.set_location(' Leaving:'||l_proc, 10);
251 End insert_validate;
252 --
253 -- ----------------------------------------------------------------------------
254 -- |---------------------------< update_validate >----------------------------|
255 -- ----------------------------------------------------------------------------
256 Procedure update_validate(p_rec in pqh_att_shd.g_rec_type
257                          ,p_effective_date in date) is
258 --
259   l_proc  varchar2(72) := g_package||'update_validate';
260 --
261 Begin
262   hr_utility.set_location('Entering:'||l_proc, 5);
263   --
264   -- Call all supporting business operations
265   --
266   chk_attribute_id
267   (p_attribute_id          => p_rec.attribute_id,
268    p_object_version_number => p_rec.object_version_number);
269   --
270   chk_master_attribute_id
271   (p_attribute_id          => p_rec.attribute_id,
272    p_master_attribute_id          => p_rec.master_attribute_id,
273    p_object_version_number => p_rec.object_version_number);
274   --
275   chk_enable_flag
276   (p_attribute_id          => p_rec.attribute_id,
277    p_enable_flag         => p_rec.enable_flag,
278    p_effective_date        => p_effective_date,
279    p_object_version_number => p_rec.object_version_number);
280   --
281   --
282   --
283   hr_utility.set_location(' Leaving:'||l_proc, 10);
284 End update_validate;
285 --
286 -- ----------------------------------------------------------------------------
287 -- |---------------------------< delete_validate >----------------------------|
288 -- ----------------------------------------------------------------------------
289 Procedure delete_validate(p_rec in pqh_att_shd.g_rec_type
290                          ,p_effective_date in date) is
291 --
292   l_proc  varchar2(72) := g_package||'delete_validate';
293 --
294 Begin
295   hr_utility.set_location('Entering:'||l_proc, 5);
296   --
297   -- Call all supporting business operations
298   --
299   hr_utility.set_location(' Leaving:'||l_proc, 10);
300 End delete_validate;
301 --
302 end pqh_att_bus;