DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_PTI_SHD

Source


1 Package Body pqh_pti_shd as
2 /* $Header: pqptirhi.pkb 120.2 2005/10/12 20:18:49 srajakum noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  pqh_pti_shd.';  -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |---------------------------< constraint_error >---------------------------|
12 -- ----------------------------------------------------------------------------
13 Procedure constraint_error
14             (p_constraint_name in all_constraints.constraint_name%TYPE) Is
15 --
16   l_proc 	varchar2(72) := g_package||'constraint_error';
17 --
18 Begin
19   hr_utility.set_location('Entering:'||l_proc, 5);
20   --
21   If (p_constraint_name = 'PQH_PTX_INFO_TYPES_PK') Then
22     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
23     hr_utility.set_message_token('PROCEDURE', l_proc);
24     hr_utility.set_message_token('STEP','5');
25     hr_utility.raise_error;
26   Else
27     hr_utility.set_message(801, 'HR_7877_API_INVALID_CONSTRAINT');
28     hr_utility.set_message_token('PROCEDURE', l_proc);
29     hr_utility.set_message_token('CONSTRAINT_NAME', p_constraint_name);
30     hr_utility.raise_error;
31   End If;
32   --
33   hr_utility.set_location(' Leaving:'||l_proc, 10);
34 End constraint_error;
35 --
36 -- ----------------------------------------------------------------------------
37 -- |-----------------------------< api_updating >-----------------------------|
38 -- ----------------------------------------------------------------------------
39 Function api_updating
40   (
41   p_information_type                   in varchar2,
42   p_object_version_number              in number
43   )      Return Boolean Is
44 --
45   --
46   -- Cursor selects the 'current' row from the HR Schema
47   --
48   Cursor C_Sel1 is
49     select
50 		information_type,
51 	active_inactive_flag,
52 	description,
53 	multiple_occurences_flag,
54 	legislation_code,
55 	object_version_number
56     from	pqh_ptx_info_types
57     where	information_type = p_information_type;
58 --
59   l_proc	varchar2(72)	:= g_package||'api_updating';
60   l_fct_ret	boolean;
61 --
62 Begin
63   hr_utility.set_location('Entering:'||l_proc, 5);
64   --
65   If (
66 	p_information_type is null and
67 	p_object_version_number is null
68      ) Then
69     --
70     -- One of the primary key arguments is null therefore we must
71     -- set the returning function value to false
72     --
73     l_fct_ret := false;
74   Else
75     If (
76 	p_information_type = g_old_rec.information_type and
77 	p_object_version_number = g_old_rec.object_version_number
78        ) Then
79       hr_utility.set_location(l_proc, 10);
80       --
81       -- The g_old_rec is current therefore we must
82       -- set the returning function to true
83       --
84       l_fct_ret := true;
85     Else
86       --
87       -- Select the current row into g_old_rec
88       --
89       Open C_Sel1;
90       Fetch C_Sel1 Into g_old_rec;
91       If C_Sel1%notfound Then
92         Close C_Sel1;
93         --
94         -- The primary key is invalid therefore we must error
95         --
96         hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
97         hr_utility.raise_error;
98       End If;
99       Close C_Sel1;
100       If (p_object_version_number <> g_old_rec.object_version_number) Then
101         hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
102         hr_utility.raise_error;
103       End If;
104       hr_utility.set_location(l_proc, 15);
105       l_fct_ret := true;
106     End If;
107   End If;
108   hr_utility.set_location(' Leaving:'||l_proc, 20);
109   Return (l_fct_ret);
110 --
111 End api_updating;
112 --
113 -- ----------------------------------------------------------------------------
114 -- |---------------------------------< lck >----------------------------------|
115 -- ----------------------------------------------------------------------------
116 Procedure lck
117   (
118   p_information_type                   in varchar2,
119   p_object_version_number              in number
120   ) is
121 --
122 -- Cursor selects the 'current' row from the HR Schema
123 --
124   Cursor C_Sel1 is
125     select 	information_type,
126 	active_inactive_flag,
127 	description,
128 	multiple_occurences_flag,
129 	legislation_code,
130 	object_version_number
131     from	pqh_ptx_info_types
132     where	information_type = p_information_type
133     for	update nowait;
134 --
135   l_proc	varchar2(72) := g_package||'lck';
136 --
137 Begin
138   hr_utility.set_location('Entering:'||l_proc, 5);
139   --
140   -- Add any mandatory argument checking here:
141   -- Example:
142   -- hr_api.mandatory_arg_error
143   --   (p_api_name       => l_proc,
144   --    p_argument       => 'object_version_number',
145   --    p_argument_value => p_object_version_number);
146   --
147   Open  C_Sel1;
148   Fetch C_Sel1 Into g_old_rec;
149   If C_Sel1%notfound then
150     Close C_Sel1;
151     --
152     -- The primary key is invalid therefore we must error
153     --
154     hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
155     hr_utility.raise_error;
156   End If;
157   Close C_Sel1;
158   If (p_object_version_number <> g_old_rec.object_version_number) Then
159         hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
160         hr_utility.raise_error;
161       End If;
162 --
163   hr_utility.set_location(' Leaving:'||l_proc, 10);
164 --
165 -- We need to trap the ORA LOCK exception
166 --
167 Exception
168   When HR_Api.Object_Locked then
169     --
170     -- The object is locked therefore we need to supply a meaningful
171     -- error message.
172     --
173     hr_utility.set_message(801, 'HR_7165_OBJECT_LOCKED');
174     hr_utility.set_message_token('TABLE_NAME', 'pqh_ptx_info_types');
175     hr_utility.raise_error;
176 End lck;
177 --
178 -- ----------------------------------------------------------------------------
179 -- |-----------------------------< convert_args >-----------------------------|
180 -- ----------------------------------------------------------------------------
181 Function convert_args
182 	(
183 	p_information_type              in varchar2,
184 	p_active_inactive_flag          in varchar2,
185 	p_description                   in varchar2,
186 	p_multiple_occurences_flag      in varchar2,
187 	p_legislation_code              in varchar2,
188 	p_object_version_number         in number
189 	)
190 	Return g_rec_type is
191 --
192   l_rec	  g_rec_type;
193   l_proc  varchar2(72) := g_package||'convert_args';
194 --
195 Begin
196   --
197   hr_utility.set_location('Entering:'||l_proc, 5);
198   --
199   -- Convert arguments into local l_rec structure.
200   --
201   l_rec.information_type                 := p_information_type;
202   l_rec.active_inactive_flag             := p_active_inactive_flag;
203   l_rec.description                      := p_description;
204   l_rec.multiple_occurences_flag         := p_multiple_occurences_flag;
205   l_rec.legislation_code                 := p_legislation_code;
206   l_rec.object_version_number            := p_object_version_number;
207   --
208   -- Return the plsql record structure.
209   --
210   hr_utility.set_location(' Leaving:'||l_proc, 10);
211   Return(l_rec);
212 --
213 End convert_args;
214 --
215 --
216 -- ----------------------------------------------------------------------------
217 -- |------------------------< LOAD_ROW >----------------------|
218 -- ----------------------------------------------------------------------------
219 --
220 procedure LOAD_ROW
221   (p_information_type               in  varchar2
222   ,p_active_inactive_flag           in  varchar2
223   ,p_description                    in  varchar2
224   ,p_multiple_occurences_flag       in  varchar2
225   ,p_legislation_code               in  varchar2
226   ,p_owner			    in  varchar2
227   ,p_last_update_date               in varchar2
228   ) is
229 l_created_by        number;
230 l_last_updated_by   number;
231 l_creation_date        date;
232 l_last_update_date  date;
233 l_last_update_login number;
234 l_updated    number := 0;
235 cursor c0 is
236    select pti.* from pqh_ptx_info_types pti
237    where information_type = p_information_type
238    for update;
239 --
240 l_data_migrator_mode varchar2(1);
241 --
242 begin
243 --
244 --
245 -- populate WHO columns
246 --
247   /**
248   if p_owner = 'SEED' then
249     l_created_by := 1;
250     l_last_updated_by := -1;
251   else
252     l_created_by := 0;
253     l_last_updated_by := 0;
254   end if;
255   **/
256      l_data_migrator_mode := hr_general.g_data_migrator_mode ;
257    hr_general.g_data_migrator_mode := 'Y';
258   l_last_updated_by := fnd_load_util.owner_id(p_owner);
259   l_created_by := fnd_load_util.owner_id(p_owner);
260     l_creation_date := nvl(to_date(p_last_update_date,'YYYY/MM/DD'),trunc(sysdate));
261   l_last_update_date := nvl(to_date(p_last_update_date,'YYYY/MM/DD'),trunc(sysdate));
262 /**
263   l_creation_date := trunc(sysdate);
264   l_last_update_date := trunc(sysdate);
265 **/
266   l_last_update_login := 0;
267 
268 --
269   for r0 in c0 loop
270     if NVL(r0.last_updated_by,-1) in (l_last_updated_by,1,-1) then
271     update pqh_ptx_info_types
272       set
273         active_inactive_flag                = p_active_inactive_flag,
274         description                         = p_description,
275         multiple_occurences_flag            = p_multiple_occurences_flag,
276         legislation_code                    = p_legislation_code,
277         last_updated_by                     = l_last_updated_by,
278         last_update_date                    = l_last_update_date,
279         last_update_login                   = l_last_update_login
280       where current of c0;
281     end if;
282     l_updated := 1;
283   end loop;
284   if l_updated = 0 then
285     insert into pqh_ptx_info_types(
286         information_type,
287         active_inactive_flag,
288         description,
289         multiple_occurences_flag,
290         legislation_code,
291         object_version_number,
292         last_update_date,
293         last_updated_by,
294         last_update_login,
295         created_by,
296         creation_date
297       )
298     Values(
299         p_information_type,
300         p_active_inactive_flag,
301         p_description,
302         p_multiple_occurences_flag,
303         p_legislation_code,
304         1,
305         l_last_update_date,
306         l_last_updated_by,
307         l_last_update_login,
308         l_created_by,
309         l_creation_date
310       );
311   end if;
312    hr_general.g_data_migrator_mode := l_data_migrator_mode;
313  --
314 End load_row;
315 --
316 end pqh_pti_shd;