1 Package Body hr_lot_bus as
2 /* $Header: hrlotrhi.pkb 115.10 2002/12/04 05:45:04 hjonnala ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 -- Added for Bug 957239
9 g_business_group_id number(15); -- For validating translation;
10 g_legislation_code varchar2(150); -- For validating translation;
11
12 g_package varchar2(33) := ' hr_lot_bus.'; -- Global package name
13 -- Proc Added for Bug 957239
14 -- ----------------------------------------------------------------------------
15 -- |---------------------------< set_translation_globals >--------------------|
16 --------------------------------------------------------------------------------
17 PROCEDURE set_translation_globals(p_business_group_id IN NUMBER,
18 p_legislation_code IN VARCHAR2) IS
19 BEGIN
20 g_business_group_id := p_business_group_id;
21 g_legislation_code := p_legislation_code;
22 END;
23 --------------------------------------------------------------------------------
24 --
28 --
25 -- ----------------------------------------------------------------------------
26 -- |---------------------------< chk_location_code >--------------------------|
27 -- ----------------------------------------------------------------------------
29 -- Description
30 -- This procedure is used to check that the location code is unique within
31 -- its language and business_group (if set). If the business_group_id is
32 -- null, the code must be unique within the language.
33 --
34 -- Pre Conditions
35 -- None.
36 --
37 -- In Parameters
38 --
39 -- p_language_id
40 -- p_location_code
41 -- p_language
42 -- p_business_group_id
43 --
44 --
45 -- Post Success
46 -- Processing continues
47 --
48 -- Post Failure
49 -- Errors handled by the procedure
50 --
51 -- Access Status
52 -- Internal table handler use only.
53 --
54 procedure chk_location_code
55 (
56 p_location_id in number,
57 p_location_code in varchar2,
58 p_language in varchar2,
59 p_business_group_id in number,
60 p_called_from_form in boolean
61 )
62 is
63 -- Cursor to check whether a location_code is unique within
64 -- a particular locations belonging to a particular business group
65 -- and witin all global locations. Used if p_business_group_id
66 -- is NOT NULL
67 -- 969354: Code check should be case insensitive
68 --
69 cursor csr_chk_location_codes is
70 select null
71 from hr_locations_all loc, hr_locations_all_tl lot
72 where lot.location_id <> nvl(p_location_id, -99)
73 and lot.language = p_language
74 and upper(lot.location_code) = upper(p_location_code)
75 and lot.location_id = loc.location_id
76 and ( loc.business_group_id +0 is null
77 or p_business_group_id is null
78 or loc.business_group_id +0 = p_business_group_id );
79 --
80 --
81 l_proc varchar2(72) := g_package||'chk_location_code';
82 l_exists varchar2(1);
83 l_api_updating boolean;
84 --
85 Begin
86 --
87 hr_utility.set_location('Entering:'||l_proc, 5);
88 --
89 l_api_updating := hr_lot_shd.api_updating ( p_location_id,
90 p_language);
91
92 if (l_api_updating and nvl(hr_lot_shd.g_old_rec.location_code, hr_api.g_varchar2) <>
93 nvl(p_location_code, hr_api.g_varchar2) )
94 or (NOT l_api_updating) THEN
95 --
96 -- See if location_code unique within all locations_codes
97 -- for a particular language;
98 --
99 open csr_chk_location_codes;
100 fetch csr_chk_location_codes into l_exists;
101 --
102 if csr_chk_location_codes%found then
103 close csr_chk_location_codes;
104 --
105 -- The location code is not unique, so report error.
106 if p_called_from_form then
107 --
108 -- If calling
109 -- directly from form, use a differrent message (on the form,
110 -- the field name for LOCATION_CODE is 'Name')
111 --
112 hr_utility.set_message(800, 'PER_52516_INV_LOCATION_NAME');
113 else
114 hr_utility.set_message(800, 'PER_52507_INV_LOCATION_CODE');
115 end if;
116 --
117 hr_utility.raise_error;
118 end if;
119 --
120 close csr_chk_location_codes;
121 --
122 end if;
123 --
124 hr_utility.set_location('Leaving:'||l_proc, 10);
125 --
126 end chk_location_code;
127 -- --
128 --
129 -- ----------------------------------------------------------------------------
130 -- |---------------------------< chk_location_code overload >----------------|
131 -- ----------------------------------------------------------------------------
132 --
133 -- Description
134 -- This procedure is used to check that the location code is unique within
135 -- its language and business_group (if set). If the business_group_id is
136 -- null, the code must be unique within the language.
137 --
138 -- This version is overloaded as this versions is used instead of
139 -- hr_location_api.validate_translation call in perwsloc.fmb
140 -- Pre Conditions
141 -- None.
142 --
143 -- In Parameters
144 --
145 -- language_id
146 -- location_code
147 -- language
148 -- description ( dummy param ,used to allow the form to compile )
149 --
150 --
151 -- Post Success
152 -- Processing continues
153 --
154 -- Post Failure
155 -- Errors handled by the client
156 --
157 -- Access Status
158 -- Used for call from Client code
159 procedure chk_location_code(location_id IN NUMBER,
160 language IN VARCHAR2,
161 location_code IN VARCHAR2,
162 description IN VARCHAR2)
163 is
164 begin
165 -- Since this is just a wrapper for call from clients
166 -- there is no standard hr_utility.set_locations calls
167 -- This will make the proc transperant
168 hr_lot_bus.chk_location_code(
169 p_location_id => location_id
170 ,p_location_code => location_code
171 ,p_language => language
172 ,p_business_group_id => g_business_group_id
173 ,p_called_from_form => TRUE
174 );
175 end chk_location_code;
176 --
177 -- ----------------------------------------------------------------------------
178 -- |---------------------------< insert_validate >----------------------------|
179 -- ----------------------------------------------------------------------------
180 Procedure insert_validate ( p_rec in hr_lot_shd.g_rec_type,
181 p_business_group_id in number)
182 is
183 --
184 l_proc varchar2(72) := g_package||'insert_validate';
185 --
186 Begin
187 hr_utility.set_location('Entering:'||l_proc, 5);
188 --
189 -- Call all supporting business operations
190 --
191 -- Location code must be unique within the set of codes
192 -- with the same language and scope determined by
193 -- business_group_id
194 --
195 -- p_location_id should always be NULL on insert.
196 --
197 chk_location_code
198 (
199 p_location_id => p_rec.location_id,
200 p_location_code => p_rec.location_code,
201 p_language => p_rec.language,
202 p_business_group_id => p_business_group_id,
203 p_called_from_form => FALSE
204 );
205 --
206 --
207 hr_utility.set_location(' Leaving:'||l_proc, 10);
208 End insert_validate;
209 --
210 -- ----------------------------------------------------------------------------
211 -- |---------------------------< update_validate >----------------------------|
212 -- ----------------------------------------------------------------------------
213 Procedure update_validate( p_rec in hr_lot_shd.g_rec_type,
214 p_business_group_id in number )
215 is
216 --
217 l_proc varchar2(72) := g_package||'update_validate';
218 --
219 Begin
220 hr_utility.set_location('Entering:'||l_proc, 5);
221 --
222 -- Call all supporting business operations
223 --
224 -- Location code must be unique within the set of codes
225 -- with the same language and scope determined by
226 -- business_group_id
227 --
228 chk_location_code
229 (
230 p_location_id => p_rec.location_id,
231 p_location_code => p_rec.location_code,
232 p_language => p_rec.language,
233 p_business_group_id => p_business_group_id,
234 p_called_from_form => FALSE
235 );
236 --
237 --
238 hr_utility.set_location(' Leaving:'||l_proc, 10);
239 End update_validate;
240 --
241 -- ----------------------------------------------------------------------------
242 -- |---------------------------< delete_validate >----------------------------|
243 -- ----------------------------------------------------------------------------
244 Procedure delete_validate(p_rec in hr_lot_shd.g_rec_type) is
245 --
246 l_proc varchar2(72) := g_package||'delete_validate';
247 --
248 Begin
249 hr_utility.set_location('Entering:'||l_proc, 5);
250 --
251 -- Call all supporting business operations
252 --
253 hr_utility.set_location(' Leaving:'||l_proc, 10);
254 End delete_validate;
255 --
256 end hr_lot_bus;