DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_CEA_BUS

Source


1 Package Body pqh_cea_bus as
2 /* $Header: pqcearhi.pkb 115.5 2003/09/28 21:33:49 scnair ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  pqh_cea_bus.';  -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |------< chk_copy_entity_attrib_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 --   copy_entity_attrib_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_copy_entity_attrib_id(p_copy_entity_attrib_id                in number,
37                            p_object_version_number       in number) is
38   --
39   l_proc         varchar2(72) := g_package||'chk_copy_entity_attrib_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_cea_shd.api_updating
47     (p_copy_entity_attrib_id                => p_copy_entity_attrib_id,
48      p_object_version_number       => p_object_version_number);
49   --
50   if (l_api_updating
51      and nvl(p_copy_entity_attrib_id,hr_api.g_number)
52      <>  pqh_cea_shd.g_old_rec.copy_entity_attrib_id) then
53     --
54     -- raise error as PK has changed
55     --
56     pqh_cea_shd.constraint_error('PQH_COPY_ENTITY_ATTRIBS_PK');
57     --
58   elsif not l_api_updating then
59     --
60     -- check if PK is null
61     --
62     if p_copy_entity_attrib_id is not null then
63       --
64       -- raise error as PK is not null
65       --
66       pqh_cea_shd.constraint_error('PQH_COPY_ENTITY_ATTRIBS_PK');
67       --
68     end if;
69     --
70   end if;
71   --
72   hr_utility.set_location('Leaving:'||l_proc, 10);
73   --
74 End chk_copy_entity_attrib_id;
75 --
76 -- ----------------------------------------------------------------------------
77 -- |------< chk_copy_entity_txn_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_copy_entity_attrib_id PK
89 --   p_copy_entity_txn_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_copy_entity_txn_id (p_copy_entity_attrib_id          in number,
102                             p_copy_entity_txn_id          in number,
103                             p_object_version_number in number) is
104   --
105   l_proc         varchar2(72) := g_package||'chk_copy_entity_txn_id';
106   l_api_updating boolean;
107   l_dummy        varchar2(1);
108   --
109   cursor c1 is
110     select null
111     from   pqh_copy_entity_txns a
112     where  a.copy_entity_txn_id = p_copy_entity_txn_id;
113   --
114 Begin
115   --
116   hr_utility.set_location('Entering:'||l_proc,5);
117   --
118   l_api_updating := pqh_cea_shd.api_updating
119      (p_copy_entity_attrib_id            => p_copy_entity_attrib_id,
120       p_object_version_number   => p_object_version_number);
121   --
122   if (l_api_updating
123      and nvl(p_copy_entity_txn_id,hr_api.g_number)
124      <> nvl(pqh_cea_shd.g_old_rec.copy_entity_txn_id,hr_api.g_number)
125      or not l_api_updating) then
126     --
127     -- check if copy_entity_txn_id value exists in pqh_copy_entity_txns table
128     --
129     open c1;
130       --
131       fetch c1 into l_dummy;
132       if c1%notfound then
133         --
134         close c1;
135         --
136         -- raise error as FK does not relate to PK in pqh_copy_entity_txns
137         -- table.
138         --
139         pqh_cea_shd.constraint_error('PQH_COPY_ENTITY_ATTRIBS_FK1');
140         --
141       end if;
142       --
143     close c1;
144     --
145   end if;
146   --
147   hr_utility.set_location('Leaving:'||l_proc,10);
148   --
149 End chk_copy_entity_txn_id;
150 --
151 -- ----------------------------------------------------------------------------
152 -- |------< chk_row_type_cd >------|
153 -- ----------------------------------------------------------------------------
154 --
155 -- Description
156 --   This procedure is used to check that the lookup value is valid.
157 --
158 -- Pre Conditions
159 --   None.
160 --
161 -- In Parameters
162 --   copy_entity_attrib_id PK of record being inserted or updated.
163 --   row_type_cd Value of lookup code.
164 --   effective_date effective date
165 --   object_version_number Object version number of record being
166 --                         inserted or updated.
167 --
168 -- Post Success
169 --   Processing continues
170 --
171 -- Post Failure
172 --   Error handled by procedure
173 --
174 -- Access Status
175 --   Internal table handler use only.
176 --
177 Procedure chk_row_type_cd(p_copy_entity_attrib_id                in number,
178                             p_row_type_cd               in varchar2,
179                             p_effective_date              in date,
180                             p_object_version_number       in number) is
181   --
182   l_proc         varchar2(72) := g_package||'chk_row_type_cd';
183   l_api_updating boolean;
184   --
185 Begin
186   --
187   hr_utility.set_location('Entering:'||l_proc, 5);
188   --
189   l_api_updating := pqh_cea_shd.api_updating
190     (p_copy_entity_attrib_id                => p_copy_entity_attrib_id,
191      p_object_version_number       => p_object_version_number);
192   --
193   if (l_api_updating
194       and p_row_type_cd
195       <> nvl(pqh_cea_shd.g_old_rec.row_type_cd,hr_api.g_varchar2)
196       or not l_api_updating)
197       and p_row_type_cd is not null then
198     --
199     -- check if value of lookup falls within lookup type.
200     --
201     if hr_api.not_exists_in_hr_lookups
202           (p_lookup_type    => 'ENTER-LKP-TYPE',
203            p_lookup_code    => p_row_type_cd,
204            p_effective_date => p_effective_date) then
205       --
206       -- raise error as does not exist as lookup
207       --
208       hr_utility.set_message(801,'HR_LOOKUP_DOES_NOT_EXIST');
209 --      hr_utility.raise_error;
210       --
211     end if;
212     --
213   end if;
214   --
215   hr_utility.set_location('Leaving:'||l_proc,10);
216   --
217 end chk_row_type_cd;
218 --
219 -- ----------------------------------------------------------------------------
220 -- |---------------------------< insert_validate >----------------------------|
221 -- ----------------------------------------------------------------------------
222 Procedure insert_validate(p_rec in pqh_cea_shd.g_rec_type
223                          ,p_effective_date in date) is
224 --
225   l_proc  varchar2(72) := g_package||'insert_validate';
226 --
227 Begin
228   hr_utility.set_location('Entering:'||l_proc, 5);
229   --
230   -- Call all supporting business operations
231   --
232   chk_copy_entity_attrib_id
233   (p_copy_entity_attrib_id          => p_rec.copy_entity_attrib_id,
234    p_object_version_number => p_rec.object_version_number);
235   --
236   chk_copy_entity_txn_id
237   (p_copy_entity_attrib_id          => p_rec.copy_entity_attrib_id,
238    p_copy_entity_txn_id          => p_rec.copy_entity_txn_id,
239    p_object_version_number => p_rec.object_version_number);
240   --
241   chk_row_type_cd
242   (p_copy_entity_attrib_id          => p_rec.copy_entity_attrib_id,
243    p_row_type_cd         => p_rec.row_type_cd,
244    p_effective_date        => p_effective_date,
245    p_object_version_number => p_rec.object_version_number);
246   --
247   --
248   --
249   hr_utility.set_location(' Leaving:'||l_proc, 10);
250 End insert_validate;
251 --
252 -- ----------------------------------------------------------------------------
253 -- |---------------------------< update_validate >----------------------------|
254 -- ----------------------------------------------------------------------------
255 Procedure update_validate(p_rec in pqh_cea_shd.g_rec_type
256                          ,p_effective_date in date) is
257 --
258   l_proc  varchar2(72) := g_package||'update_validate';
259 --
260 Begin
261   hr_utility.set_location('Entering:'||l_proc, 5);
262   --
263   -- Call all supporting business operations
264   --
265   chk_copy_entity_attrib_id
266   (p_copy_entity_attrib_id          => p_rec.copy_entity_attrib_id,
267    p_object_version_number => p_rec.object_version_number);
268   --
269   chk_copy_entity_txn_id
270   (p_copy_entity_attrib_id          => p_rec.copy_entity_attrib_id,
271    p_copy_entity_txn_id          => p_rec.copy_entity_txn_id,
272    p_object_version_number => p_rec.object_version_number);
273   --
274   chk_row_type_cd
275   (p_copy_entity_attrib_id          => p_rec.copy_entity_attrib_id,
276    p_row_type_cd         => p_rec.row_type_cd,
277    p_effective_date        => p_effective_date,
278    p_object_version_number => p_rec.object_version_number);
279   --
280   --
281   --
282   hr_utility.set_location(' Leaving:'||l_proc, 10);
283 End update_validate;
284 --
285 -- ----------------------------------------------------------------------------
286 -- |---------------------------< delete_validate >----------------------------|
287 -- ----------------------------------------------------------------------------
288 Procedure delete_validate(p_rec in pqh_cea_shd.g_rec_type
289                          ,p_effective_date in date) is
290 --
291   l_proc  varchar2(72) := g_package||'delete_validate';
292 --
293 Begin
294   hr_utility.set_location('Entering:'||l_proc, 5);
295   --
296   -- Call all supporting business operations
297   --
298   hr_utility.set_location(' Leaving:'||l_proc, 10);
299 End delete_validate;
300 --
301 end pqh_cea_bus;