DBA Data[Home] [Help]

PACKAGE BODY: APPS.OTA_ANT_SHD

Source


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