[Home] [Help]
PACKAGE BODY: APPS.PQH_CTL_SHD
Source
1 Package Body pqh_ctl_shd as
2 /* $Header: pqctlrhi.pkb 120.1 2005/08/06 13:16:22 srajakum noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' pqh_ctl_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_transaction_category_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 transaction_category_id,
45 name,
46 language,
47 source_lang
48 from pqh_transaction_categories_tl
49 where transaction_category_id = p_transaction_category_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_transaction_category_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_transaction_category_id = g_old_rec.transaction_category_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_transaction_category_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 transaction_category_id,
116 name,
117 language,
118 source_lang
119 from pqh_transaction_categories_tl
120 where transaction_category_id = p_transaction_category_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_transaction_categories_tl');
161 hr_utility.raise_error;
162 End lck;
163 --
164 -- ----------------------------------------------------------------------------
165 -- |-----------------------------< convert_args >-----------------------------|
166 -- ----------------------------------------------------------------------------
167 Function convert_args
168 (
169 p_transaction_category_id in number,
170 p_name in varchar2,
171 p_language in varchar2,
172 p_source_lang in varchar2
173 )
174 Return g_rec_type is
175 --
176 l_rec g_rec_type;
177 l_proc varchar2(72) := g_package||'convert_args';
178 --
179 Begin
180 --
181 hr_utility.set_location('Entering:'||l_proc, 5);
182 --
183 -- Convert arguments into local l_rec structure.
184 --
185 l_rec.transaction_category_id := p_transaction_category_id;
186 l_rec.name := p_name;
187 l_rec.language := p_language;
188 l_rec.source_lang := p_source_lang;
189 --
190 -- Return the plsql record structure.
191 --
192 hr_utility.set_location(' Leaving:'||l_proc, 10);
193 Return(l_rec);
194 --
195 End convert_args;
196 --
197 -- --------------------------------------ADD LANGUAGE ------------------------
198 --
199
200 procedure ADD_LANGUAGE
201 is
202 begin
203 delete from PQH_TRANSACTION_CATEGORIES_TL T
204 where not exists
205 (select NULL
206 from PQH_TRANSACTION_CATEGORIES B
207 where B.TRANSACTION_CATEGORY_ID = T.TRANSACTION_CATEGORY_ID
208 );
209
210 update PQH_TRANSACTION_CATEGORIES_TL T set (
211 NAME
212 ) = (select
213 B.NAME
214 from PQH_TRANSACTION_CATEGORIES_TL B
215 where B.TRANSACTION_CATEGORY_ID = T.TRANSACTION_CATEGORY_ID
216 and B.LANGUAGE = T.SOURCE_LANG)
217 where (
218 T.TRANSACTION_CATEGORY_ID,
219 T.LANGUAGE
220 ) in (select
221 SUBT.TRANSACTION_CATEGORY_ID,
222 SUBT.LANGUAGE
223 from PQH_TRANSACTION_CATEGORIES_TL SUBB, PQH_TRANSACTION_CATEGORIES_TL SUBT
224 where SUBB.TRANSACTION_CATEGORY_ID = SUBT.TRANSACTION_CATEGORY_ID
225 and SUBB.LANGUAGE = SUBT.SOURCE_LANG
226 and (SUBB.NAME <> SUBT.NAME
227 ));
228
229 insert into PQH_TRANSACTION_CATEGORIES_TL (
230 TRANSACTION_CATEGORY_ID,
231 NAME,
232 LAST_UPDATE_DATE,
233 CREATION_DATE,
234 CREATED_BY,
235 LAST_UPDATE_LOGIN,
236 LAST_UPDATED_BY,
237 LANGUAGE,
238 SOURCE_LANG
239 ) select
240 B.TRANSACTION_CATEGORY_ID,
241 B.NAME,
242 B.LAST_UPDATE_DATE,
243 B.CREATION_DATE,
244 B.CREATED_BY,
245 B.LAST_UPDATE_LOGIN,
246 B.LAST_UPDATED_BY,
247 L.LANGUAGE_CODE,
248 B.SOURCE_LANG
249 from PQH_TRANSACTION_CATEGORIES_TL B, FND_LANGUAGES L
250 where L.INSTALLED_FLAG in ('I', 'B')
251 and B.LANGUAGE = userenv('LANG')
252 and not exists
253 (select NULL
254 from PQH_TRANSACTION_CATEGORIES_TL T
255 where T.TRANSACTION_CATEGORY_ID = B.TRANSACTION_CATEGORY_ID
256 and T.LANGUAGE = L.LANGUAGE_CODE);
257 --
258 end ADD_LANGUAGE;
259 --
260 end pqh_ctl_shd;