DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_ATL_SHD

Source


1 Package Body pqh_atl_shd as
2 /* $Header: pqatlrhi.pkb 120.2 2006/05/23 15:58:59 srajakum ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  pqh_atl_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     hr_utility.set_message(801, 'HR_7877_API_INVALID_CONSTRAINT');
23     hr_utility.set_message_token('PROCEDURE', l_proc);
24     hr_utility.set_message_token('CONSTRAINT_NAME', p_constraint_name);
25     hr_utility.raise_error;
26   --
27   hr_utility.set_location(' Leaving:'||l_proc, 10);
28 End constraint_error;
29 --
30 -- ----------------------------------------------------------------------------
31 -- |-----------------------------< api_updating >-----------------------------|
32 -- ----------------------------------------------------------------------------
33 Function api_updating
34   (
35   p_attribute_id                       in number,
36   p_language                           in varchar2
37   )      Return Boolean Is
38 --
39   --
40   -- Cursor selects the 'current' row from the HR Schema
41   --
42   Cursor C_Sel1 is
43     select
44 		attribute_id,
45 	attribute_name,
46 	language,
47 	source_lang
48     from	pqh_attributes_tl
49     where	attribute_id = p_attribute_id
50   and   language = p_language;
51 --
52   l_proc	varchar2(72)	:= g_package||'api_updating';
53   l_fct_ret	boolean;
54 --
55 Begin
56   hr_utility.set_location('Entering:'||l_proc, 5);
57   --
58   If (
59 	p_attribute_id is null or
60 	p_language is null
61      ) Then
62     --
63     -- One of the primary key arguments is null therefore we must
64     -- set the returning function value to false
65     --
66     l_fct_ret := false;
67   Else
68     If (
69 	p_attribute_id = g_old_rec.attribute_id and
70 	p_language = g_old_rec.language
71        ) Then
72       hr_utility.set_location(l_proc, 10);
73       --
74       -- The g_old_rec is current therefore we must
75       -- set the returning function to true
76       --
77       l_fct_ret := true;
78     Else
79       --
80       -- Select the current row into g_old_rec
81       --
82       Open C_Sel1;
83       Fetch C_Sel1 Into g_old_rec;
84       If C_Sel1%notfound Then
85         Close C_Sel1;
86         --
87         -- The primary key is invalid therefore we must error
88         --
89         hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
90         hr_utility.raise_error;
91       End If;
92       Close C_Sel1;
93       --
94       hr_utility.set_location(l_proc, 15);
95       l_fct_ret := true;
96     End If;
97   End If;
98   hr_utility.set_location(' Leaving:'||l_proc, 20);
99   Return (l_fct_ret);
100 --
101 End api_updating;
102 --
103 -- ----------------------------------------------------------------------------
104 -- |---------------------------------< lck >----------------------------------|
105 -- ----------------------------------------------------------------------------
106 Procedure lck
107   (
108   p_attribute_id                       in number,
109   p_language                           in varchar2
110   ) is
111 --
112 -- Cursor selects the 'current' row from the HR Schema
113 --
114   Cursor C_Sel1 is
115     select 	attribute_id,
116 	attribute_name,
117 	language,
118 	source_lang
119     from	pqh_attributes_tl
120     where	attribute_id = p_attribute_id
121   and   language = p_language
122     for	update nowait;
123 --
124   l_proc	varchar2(72) := g_package||'lck';
125 --
126 Begin
127   hr_utility.set_location('Entering:'||l_proc, 5);
128   --
129   -- Add any mandatory argument checking here:
130   -- Example:
131   -- hr_api.mandatory_arg_error
132   --   (p_api_name       => l_proc,
133   --    p_argument       => 'object_version_number',
134   --    p_argument_value => p_object_version_number);
135   --
136   Open  C_Sel1;
137   Fetch C_Sel1 Into g_old_rec;
138   If C_Sel1%notfound then
139     Close C_Sel1;
140     --
141     -- The primary key is invalid therefore we must error
142     --
143     hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
144     hr_utility.raise_error;
145   End If;
146   Close C_Sel1;
147   --
148 --
149   hr_utility.set_location(' Leaving:'||l_proc, 10);
150 --
151 -- We need to trap the ORA LOCK exception
152 --
153 Exception
154   When HR_Api.Object_Locked then
155     --
156     -- The object is locked therefore we need to supply a meaningful
157     -- error message.
158     --
159     hr_utility.set_message(801, 'HR_7165_OBJECT_LOCKED');
160     hr_utility.set_message_token('TABLE_NAME', 'pqh_attributes_tl');
161     hr_utility.raise_error;
162 End lck;
163 --
164 ----------------------- ADD LANGUAGE --------------------------------------
165 --
166 Procedure ADD_LANGUAGE
167 is
168 begin
169   delete from PQH_ATTRIBUTES_TL T
170   where not exists
171     (select NULL
172     from PQH_ATTRIBUTES B
173     where B.ATTRIBUTE_ID = T.ATTRIBUTE_ID
174     );
175 
176   update PQH_ATTRIBUTES_TL T set (
177       ATTRIBUTE_NAME
178     ) = (select
179       B.ATTRIBUTE_NAME
180     from PQH_ATTRIBUTES_TL B
181     where B.ATTRIBUTE_ID = T.ATTRIBUTE_ID
182     and B.LANGUAGE = T.SOURCE_LANG)
183   where (
184       T.ATTRIBUTE_ID,
185       T.LANGUAGE
186   ) in (select
187       SUBT.ATTRIBUTE_ID,
188       SUBT.LANGUAGE
189     from PQH_ATTRIBUTES_TL SUBB, PQH_ATTRIBUTES_TL SUBT
190     where SUBB.ATTRIBUTE_ID = SUBT.ATTRIBUTE_ID
191     and SUBB.LANGUAGE = SUBT.SOURCE_LANG
192     and (SUBB.ATTRIBUTE_NAME <> SUBT.ATTRIBUTE_NAME
193   ));
194 
195   insert into PQH_ATTRIBUTES_TL (
196     ATTRIBUTE_ID,
197     ATTRIBUTE_NAME,
198     LAST_UPDATE_DATE,
199     CREATION_DATE,
200     CREATED_BY,
201     LAST_UPDATE_LOGIN,
202     LAST_UPDATED_BY,
203     LANGUAGE,
204     SOURCE_LANG
205   ) select
206     B.ATTRIBUTE_ID,
207     B.ATTRIBUTE_NAME,
208     B.LAST_UPDATE_DATE,
209     B.CREATION_DATE,
210     B.CREATED_BY,
211     B.LAST_UPDATE_LOGIN,
212     B.LAST_UPDATED_BY,
213     L.LANGUAGE_CODE,
214     B.SOURCE_LANG
215   from PQH_ATTRIBUTES_TL B, FND_LANGUAGES L
216   where L.INSTALLED_FLAG in ('I', 'B')
217   and B.LANGUAGE = userenv('LANG')
218   and not exists
219     (select NULL
220     from PQH_ATTRIBUTES_TL T
221     where T.ATTRIBUTE_ID = B.ATTRIBUTE_ID
222     and T.LANGUAGE = L.LANGUAGE_CODE);
223 end ADD_LANGUAGE;
224 --
225 -- ----------------------------------------------------------------------------
226 -- |-----------------------------< convert_args >-----------------------------|
227 -- ----------------------------------------------------------------------------
228 Function convert_args
229 	(
230 	p_attribute_id                  in number,
231 	p_attribute_name                in varchar2,
232 	p_language                      in varchar2,
233 	p_source_lang                   in varchar2
234 	)
235 	Return g_rec_type is
236 --
237   l_rec	  g_rec_type;
238   l_proc  varchar2(72) := g_package||'convert_args';
239 --
240 Begin
241   --
242   hr_utility.set_location('Entering:'||l_proc, 5);
243   --
244   -- Convert arguments into local l_rec structure.
245   --
246   l_rec.attribute_id                     := p_attribute_id;
247   l_rec.attribute_name                   := p_attribute_name;
248   l_rec.language                         := p_language;
249   l_rec.source_lang                      := p_source_lang;
250   --
251   -- Return the plsql record structure.
252   --
253   hr_utility.set_location(' Leaving:'||l_proc, 10);
254   Return(l_rec);
255 --
256 End convert_args;
257 --
258 end pqh_atl_shd;