DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_CEC_SHD

Source


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