[Home] [Help]
PACKAGE BODY: APPS.GHR_EVH_BUS
Source
1 Package Body ghr_evh_bus as
2 /* $Header: ghevhrhi.pkb 115.2 1999/11/09 22:35:45 pkm ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ghr_evh_bus.'; -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |------< chk_event_history_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 -- event_history_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_event_history_id(p_event_history_id in number,
37 p_object_version_number in number) is
38 --
39 l_proc varchar2(72) := g_package||'chk_event_history_id';
40 l_api_updating boolean;
41 --
42 Begin
43 --
44 hr_utility.set_location('Entering:'||l_proc, 5);
45 --
46 l_api_updating := ghr_evh_shd.api_updating
47 (p_event_history_id => p_event_history_id,
48 p_object_version_number => p_object_version_number);
49 --
50 if (l_api_updating
51 and nvl(p_event_history_id,hr_api.g_number)
52 <> ghr_evh_shd.g_old_rec.event_history_id) then
53 --
54 -- raise error as PK has changed
55 --
56 ghr_evh_shd.constraint_error('GHR_EVENT_HISTORY_PK');
57 --
58 elsif not l_api_updating then
59 --
60 -- check if PK is null
61 --
62 if p_event_history_id is not null then
63 --
64 -- raise error as PK is not null
65 --
66 ghr_evh_shd.constraint_error('GHR_EVENT_HISTORY_PK');
67 --
68 end if;
69 --
70 end if;
71 --
72 hr_utility.set_location('Leaving:'||l_proc, 10);
73 --
74 End chk_event_history_id;
75 --
76 -- ----------------------------------------------------------------------------
77 -- |------< chk_event_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_event_history_id PK
89 -- p_event_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_event_id (p_event_history_id in number,
102 p_event_id in number,
103 p_object_version_number in number) is
104 --
105 l_proc varchar2(72) := g_package||'chk_event_id';
106 l_api_updating boolean;
107 l_dummy varchar2(1);
108 --
109 cursor c1 is
110 select null
111 from ghr_events a
112 where a.event_id = p_event_id;
113 --
114 Begin
115 --
116 hr_utility.set_location('Entering:'||l_proc,5);
117 --
118 l_api_updating := ghr_evh_shd.api_updating
119 (p_event_history_id => p_event_history_id,
120 p_object_version_number => p_object_version_number);
121 --
122 if (l_api_updating
123 and nvl(p_event_id,hr_api.g_number)
124 <> nvl(ghr_evh_shd.g_old_rec.event_id,hr_api.g_number)
125 or not l_api_updating) then
126 --
127 -- check if event_id value exists in ghr_events 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 ghr_events
137 -- table.
138 --
139 ghr_evh_shd.constraint_error('GHR_EVENT_HISTORY_FK');
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_event_id;
150 --
151 -- ----------------------------------------------------------------------------
152 -- |---------------------------< insert_validate >----------------------------|
153 -- ----------------------------------------------------------------------------
154 Procedure insert_validate(p_rec in ghr_evh_shd.g_rec_type) is
155 --
156 l_proc varchar2(72) := g_package||'insert_validate';
157 --
158 Begin
159 hr_utility.set_location('Entering:'||l_proc, 5);
160 --
161 -- Call all supporting business operations
162 --
163 chk_event_history_id
164 (p_event_history_id => p_rec.event_history_id,
165 p_object_version_number => p_rec.object_version_number);
166 --
167 chk_event_id
168 (p_event_history_id => p_rec.event_history_id,
169 p_event_id => p_rec.event_id,
170 p_object_version_number => p_rec.object_version_number);
171 --
172 --
173 --
174 hr_utility.set_location(' Leaving:'||l_proc, 10);
175 End insert_validate;
176 --
177 -- ----------------------------------------------------------------------------
178 -- |---------------------------< update_validate >----------------------------|
179 -- ----------------------------------------------------------------------------
180 Procedure update_validate(p_rec in ghr_evh_shd.g_rec_type) is
181 --
182 l_proc varchar2(72) := g_package||'update_validate';
183 --
184 Begin
185 hr_utility.set_location('Entering:'||l_proc, 5);
186 --
187 -- Call all supporting business operations
188 --
189 chk_event_history_id
190 (p_event_history_id => p_rec.event_history_id,
191 p_object_version_number => p_rec.object_version_number);
192 --
193 chk_event_id
194 (p_event_history_id => p_rec.event_history_id,
195 p_event_id => p_rec.event_id,
196 p_object_version_number => p_rec.object_version_number);
197 --
198 --
199 --
200 hr_utility.set_location(' Leaving:'||l_proc, 10);
201 End update_validate;
202 --
203 -- ----------------------------------------------------------------------------
204 -- |---------------------------< delete_validate >----------------------------|
205 -- ----------------------------------------------------------------------------
206 Procedure delete_validate(p_rec in ghr_evh_shd.g_rec_type) is
207 --
208 l_proc varchar2(72) := g_package||'delete_validate';
209 --
210 Begin
211 hr_utility.set_location('Entering:'||l_proc, 5);
212 --
213 -- Call all supporting business operations
214 --
215 hr_utility.set_location(' Leaving:'||l_proc, 10);
216 End delete_validate;
217 --
218 end ghr_evh_bus;