DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_STT_SHD

Source


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