DBA Data[Home] [Help]

PACKAGE BODY: APPS.HXC_TKGQ_SHD

Source


1 Package body hxc_tkgq_shd as
2 /* $Header: hxctkgqrhi.pkb 120.2 2005/09/23 09:33:26 rchennur noship $ */
3 --
4 g_package varchar2(33) := '  hxc_tkgq_shd.';
5 g_debug boolean := hr_utility.debug_enabled;
6 -- ----------------------------------------------------------------------------
7 -- |------------------------< return_api_dml_status >-------------------------|
8 -- ----------------------------------------------------------------------------
9 Function return_api_dml_status Return Boolean Is
10 --
11 Begin
12   --
13   Return (nvl(g_api_dml, false));
14   --
15 End return_api_dml_status;
16 --
17 -- ----------------------------------------------------------------------------
18 -- |---------------------------< constraint_error >---------------------------|
19 -- ----------------------------------------------------------------------------
20 Procedure constraint_error
21   (p_constraint_name in all_constraints.constraint_name%TYPE
22   ) Is
23 --
24   l_proc        varchar2(72) := g_package||'constraint_error';
25 --
26 Begin
27   --
28   If (p_constraint_name = 'HXC_TK_GROUP_QUERIES_PK') Then
29     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
30     fnd_message.set_token('PROCEDURE', l_proc);
31     fnd_message.set_token('STEP','5');
32     fnd_message.raise_error;
33   Else
34     fnd_message.set_name('PAY', 'HR_7877_API_INVALID_CONSTRAINT');
35     fnd_message.set_token('PROCEDURE', l_proc);
36     fnd_message.set_token('CONSTRAINT_NAME', p_constraint_name);
37     fnd_message.raise_error;
38   End If;
39   --
40 End constraint_error;
41 --
42 -- ----------------------------------------------------------------------------
43 -- |-----------------------------< api_updating >-----------------------------|
44 -- ----------------------------------------------------------------------------
45 --
46 Function api_updating
47   (p_tk_group_query_id                    in     number
48   ,p_object_version_number                in     number
49   )
50   Return Boolean Is
51 --
52   --
53   -- Cursor selects the 'current' row from the HR Schema
54   --
55   Cursor C_Sel1 is
56     select
57        tk_group_query_id
58       ,tk_group_id
59       ,group_query_name
60       ,include_exclude
61       ,system_user
62       ,object_version_number
63     from	hxc_tk_group_queries tkgq
64     where	tkgq.tk_group_query_id = p_tk_group_query_id;
65 --
66   l_fct_ret	boolean;
67 --
68 Begin
69   --
70   If (p_tk_group_query_id 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 (p_tk_group_query_id
80         = hxc_tkgq_shd.g_old_rec.tk_group_query_id and
81         p_object_version_number
82         = hxc_tkgq_shd.g_old_rec.object_version_number
83        ) Then
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 hxc_tkgq_shd.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         fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
101         fnd_message.raise_error;
102       End If;
103       Close C_Sel1;
104       If (p_object_version_number
105           <> hxc_tkgq_shd.g_old_rec.object_version_number) Then
106         fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
107         fnd_message.raise_error;
108       End If;
109       l_fct_ret := true;
110     End If;
111   End If;
112   Return (l_fct_ret);
113 --
114 End api_updating;
115 --
116 -- ----------------------------------------------------------------------------
117 -- |---------------------------------< lck >----------------------------------|
118 -- ----------------------------------------------------------------------------
119 --
120 -- Description:
121 --   The Lck process has two main functions to perform. Firstly, the row to be
122 --   updated or deleted must be locked. The locking of the row will only be
123 --   successful if the row is not currently locked by another user.
124 --   Secondly, during the locking of the row, the row is selected into
125 --   the g_old_rec data structure which enables the current row values from the
126 --   server to be available to the api.
127 --
128 -- Prerequisites:
129 --   When attempting to call the lock the object version number (if defined)
130 --   is mandatory.
131 --
132 -- In Parameters:
133 --   The arguments to the Lck process are the primary key(s) which uniquely
134 --   identify the row and the object version number of row.
135 --
136 -- Post Success:
137 --   On successful completion of the Lck process the row to be updated or
138 --   deleted will be locked and selected into the global data structure
139 --   g_old_rec.
140 --
141 -- Post Failure:
142 --   The Lck process can fail for three reasons:
143 --   1) When attempting to lock the row the row could already be locked by
144 --      another user. This will raise the HR_Api.Object_Locked exception.
145 --   2) The row which is required to be locked doesn't exist in the HR Schema.
146 --      This error is trapped and reported using the message name
147 --      'HR_7220_INVALID_PRIMARY_KEY'.
148 --   3) The row although existing in the HR Schema has a different object
149 --      version number than the object version number specified.
150 --      This error is trapped and reported using the message name
151 --      'HR_7155_OBJECT_INVALID'.
152 --
153 -- Developer Implementation Notes:
154 --   For each primary key and the object version number arguments add a
155 --   call to hr_api.mandatory_arg_error procedure to ensure that these
156 --   argument values are not null.
157 --
158 -- Access Status:
159 --   Internal Development Use Only.
160 --
161 -- ----------------------------------------------------------------------------
162 Procedure lck
163   (p_tk_group_query_id                    in     number
164   ,p_object_version_number                in     number
165   ) is
166 --
167 -- Cursor selects the 'current' row from the HR Schema
168 --
169   Cursor C_Sel1 is
170     select
171        tk_group_query_id
172       ,tk_group_id
173       ,group_query_name
174       ,include_exclude
175       ,system_user
176       ,object_version_number
177     from	hxc_tk_group_queries tkgq
178     where	tkgq.tk_group_query_id = p_tk_group_query_id
179     for	update nowait;
180 --
181   l_proc	varchar2(72) ;
182 --
183 Begin
184   g_debug :=hr_utility.debug_enabled;
185   if g_debug then
186   	l_proc := g_package||'lck';
187   	hr_utility.set_location('Entering:'||l_proc, 5);
188   end if;
189   --
190   hr_api.mandatory_arg_error
191     (p_api_name           => l_proc
192     ,p_argument           => 'TK_GROUP_QUERY_ID'
193     ,p_argument_value     => p_tk_group_query_id
194     );
195   --
196   Open  C_Sel1;
197   Fetch C_Sel1 Into hxc_tkgq_shd.g_old_rec;
198   If C_Sel1%notfound then
199     Close C_Sel1;
200     --
201     -- The primary key is invalid therefore we must error
202     --
203     fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
204     fnd_message.raise_error;
205   End If;
206   Close C_Sel1;
207   If (p_object_version_number
208       <> hxc_tkgq_shd.g_old_rec.object_version_number) Then
209         fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
210         fnd_message.raise_error;
211   End If;
212   --
213   if g_debug then
214   	hr_utility.set_location(' Leaving:'||l_proc, 10);
215   end if;
216   --
217   -- We need to trap the ORA LOCK exception
218   --
219 Exception
220   When HR_Api.Object_Locked then
221     --
222     -- The object is locked therefore we need to supply a meaningful
223     -- error message.
224     --
225     fnd_message.set_name('PAY', 'HR_7165_OBJECT_LOCKED');
226     fnd_message.set_token('TABLE_NAME', 'hxc_tk_group_queries');
227     fnd_message.raise_error;
228 End lck;
229 --
230 -- ----------------------------------------------------------------------------
231 -- |-----------------------------< convert_args >-----------------------------|
232 -- ----------------------------------------------------------------------------
233 --
234 -- Description:
235 --   This function is used to turn attribute parameters into the record
236 --   structure parameter g_rec_type.
237 --
238 -- Prerequisites:
239 --   This is a private function and can only be called from the ins or upd
240 --   attribute processes.
241 --
242 -- In Parameters:
243 --
244 -- Post Success:
245 --   A returning record structure will be returned.
246 --
247 -- Post Failure:
248 --   No direct error handling is required within this function.  Any possible
249 --   errors within this function will be a PL/SQL value error due to conversion
250 --   of datatypes or data lengths.
251 --
252 -- Developer Implementation Notes:
253 --   None.
254 --
255 -- Access Status:
256 --   Internal Row Handler Use Only.
257 --
258 -- ----------------------------------------------------------------------------
259 Function convert_args
260   (p_tk_group_query_id          in number
261   ,p_tk_group_id                in number
262   ,p_group_query_name           in varchar2
263   ,p_include_exclude            in varchar2
264   ,p_system_user                in varchar2
265   ,p_object_version_number      in number
266   )
267   Return g_rec_type is
268 --
269   l_rec   g_rec_type;
270 --
271 Begin
272   --
273   -- Convert arguments into local l_rec structure.
274   --
275   l_rec.tk_group_query_id            := p_tk_group_query_id;
276   l_rec.tk_group_id                  := p_tk_group_id;
277   l_rec.group_query_name             := p_group_query_name;
278   l_rec.include_exclude              := p_include_exclude;
279   l_rec.system_user                  := p_system_user;
280   l_rec.object_version_number        := p_object_version_number;
281   --
282   -- Return the plsql record structure.
283   --
284   Return(l_rec);
285 --
286 End convert_args;
287 --
288 end hxc_tkgq_shd;