DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_DST_BUS

Source


1 Package Body pqh_dst_bus as
2 /* $Header: pqdstrhi.pkb 115.6 2002/12/05 19:32:00 rpasapul noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  pqh_dst_bus.';  -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |------< chk_dflt_budget_set_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 --   dflt_budget_set_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_dflt_budget_set_id(p_dflt_budget_set_id                in number,
37                            p_object_version_number       in number) is
38   --
39   l_proc         varchar2(72) := g_package||'chk_dflt_budget_set_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_dst_shd.api_updating
47     (p_dflt_budget_set_id                => p_dflt_budget_set_id,
48      p_object_version_number       => p_object_version_number);
49   --
50   if (l_api_updating
51      and nvl(p_dflt_budget_set_id,hr_api.g_number)
52      <>  pqh_dst_shd.g_old_rec.dflt_budget_set_id) then
53     --
54     -- raise error as PK has changed
55     --
56     pqh_dst_shd.constraint_error('PQH_DFLT_BUDGET_SETS_PK');
57     --
58   elsif not l_api_updating then
59     --
60     -- check if PK is null
61     --
62     if p_dflt_budget_set_id is not null then
63       --
64       -- raise error as PK is not null
65       --
66       pqh_dst_shd.constraint_error('PQH_DFLT_BUDGET_SETS_PK');
67       --
68     end if;
69     --
70   end if;
71   --
72   hr_utility.set_location('Leaving:'||l_proc, 10);
73   --
74 End chk_dflt_budget_set_id;
75 --
76 -- ----------------------------------------------------------------------------
77 -- |---------------------------< chk_budget_set_name >----------------------------|
78 -- ----------------------------------------------------------------------------
79 Procedure chk_budget_set_name (p_dflt_budget_set_id                in number,
80                             p_dflt_budget_set_name               in varchar2) is
81   --
82   l_proc         varchar2(72) := g_package||'chk_budget_set_name';
83   --
84 l_dummy   varchar2(1) ;
85 
86  cursor csr_budget_set_name is
87  select 'X'
88  from pqh_dflt_budget_sets
89  where dflt_budget_set_name = p_dflt_budget_set_name
90    and dflt_budget_set_id <> nvl(p_dflt_budget_set_id,0);
91 
92 Begin
93   --
94   hr_utility.set_location('Entering:'||l_proc, 5);
95   --
96   open csr_budget_set_name;
97    fetch csr_budget_set_name into l_dummy;
98   close csr_budget_set_name;
99 
100     if nvl(l_dummy ,'Y') = 'X' then
101       --
102        hr_utility.set_message(8302,'PQH_DUPLICATE_BUDGET_SET_NAME');
103        hr_utility.raise_error;
104       --
105     end if;
106 
107   --
108   hr_utility.set_location('Leaving:'||l_proc,10);
109   --
110 end chk_budget_set_name;
111 
112 -- ----------------------------------------------------------------------------
113 -- |---------------------------< insert_validate >----------------------------|
114 -- ----------------------------------------------------------------------------
115 Procedure insert_validate(p_rec in pqh_dst_shd.g_rec_type) is
116 --
117   l_proc  varchar2(72) := g_package||'insert_validate';
118 --
119 Begin
120   hr_utility.set_location('Entering:'||l_proc, 5);
121   --
122   -- Call all supporting business operations
123   --
124   chk_dflt_budget_set_id
125   (p_dflt_budget_set_id          => p_rec.dflt_budget_set_id,
126    p_object_version_number => p_rec.object_version_number);
127   --
128   chk_budget_set_name
129   (p_dflt_budget_set_id      => p_rec.dflt_budget_set_id,
130    p_dflt_budget_set_name    => p_rec.dflt_budget_set_name);
131   --
132   hr_api.validate_bus_grp_id(p_rec.business_group_id);  -- Validate Bus Grp
133   --
134   hr_utility.set_location(' Leaving:'||l_proc, 10);
135 End insert_validate;
136 --
137 -- ----------------------------------------------------------------------------
138 -- |---------------------------< update_validate >----------------------------|
139 -- ----------------------------------------------------------------------------
140 Procedure update_validate(p_rec in pqh_dst_shd.g_rec_type) is
141 --
142   l_proc  varchar2(72) := g_package||'update_validate';
143 --
144 Begin
145   hr_utility.set_location('Entering:'||l_proc, 5);
146   --
147   -- Call all supporting business operations
148   --
149   chk_dflt_budget_set_id
150   (p_dflt_budget_set_id          => p_rec.dflt_budget_set_id,
151    p_object_version_number => p_rec.object_version_number);
152   --
153   chk_budget_set_name
154   (p_dflt_budget_set_id      => p_rec.dflt_budget_set_id,
155    p_dflt_budget_set_name    => p_rec.dflt_budget_set_name);
156   --
157 
158   hr_api.validate_bus_grp_id(p_rec.business_group_id);  -- Validate Bus Grp
159   --
160   hr_utility.set_location(' Leaving:'||l_proc, 10);
161 End update_validate;
162 --
163 -- ----------------------------------------------------------------------------
164 -- |---------------------------< delete_validate >----------------------------|
165 -- ----------------------------------------------------------------------------
166 Procedure delete_validate(p_rec in pqh_dst_shd.g_rec_type) is
167 --
168   l_proc  varchar2(72) := g_package||'delete_validate';
169 --
170 Begin
171   hr_utility.set_location('Entering:'||l_proc, 5);
172   --
173   -- Call all supporting business operations
174   --
175   hr_utility.set_location(' Leaving:'||l_proc, 10);
176 End delete_validate;
177 --
178 --
179 --  ---------------------------------------------------------------------------
180 --  |---------------------< return_legislation_code >-------------------------|
181 --  ---------------------------------------------------------------------------
182 --
183 function return_legislation_code
184   (p_dflt_budget_set_id in number) return varchar2 is
185   --
186   -- Declare cursor
187   --
188   cursor csr_leg_code is
189     select a.legislation_code
190     from   per_business_groups a,
191            pqh_dflt_budget_sets b
192     where b.dflt_budget_set_id      = p_dflt_budget_set_id
193     and   a.business_group_id = b.business_group_id;
194   --
195   -- Declare local variables
196   --
197   l_legislation_code  varchar2(150);
198   l_proc              varchar2(72)  :=  g_package||'return_legislation_code';
199   --
200 begin
201   --
202   hr_utility.set_location('Entering:'|| l_proc, 10);
203   --
204   -- Ensure that all the mandatory parameter are not null
205   --
206   hr_api.mandatory_arg_error(p_api_name       => l_proc,
207                              p_argument       => 'dflt_budget_set_id',
208                              p_argument_value => p_dflt_budget_set_id);
209   --
210   open csr_leg_code;
211     --
212     fetch csr_leg_code into l_legislation_code;
213     --
214     if csr_leg_code%notfound then
215       --
216       close csr_leg_code;
217       --
218       -- The primary key is invalid therefore we must error
219       --
220       hr_utility.set_message(801,'HR_7220_INVALID_PRIMARY_KEY');
221       hr_utility.raise_error;
222       --
223     end if;
224     --
225   close csr_leg_code;
226   --
227   hr_utility.set_location(' Leaving:'|| l_proc, 20);
228   --
229   return l_legislation_code;
230   --
231 end return_legislation_code;
232 --
233 end pqh_dst_bus;