DBA Data[Home] [Help]

PACKAGE BODY: APPS.GHR_EVH_SHD

Source


1 Package Body ghr_evh_shd as
2 /* $Header: ghevhrhi.pkb 120.0.12010000.3 2009/05/27 05:37:26 utokachi noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ghr_evh_shd.';  -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |------------------------< return_api_dml_status >-------------------------|
12 -- ----------------------------------------------------------------------------
13 Function return_api_dml_status Return Boolean Is
14 --
15   l_proc 	varchar2(72) := g_package||'return_api_dml_status';
16 --
17 Begin
18   hr_utility.set_location('Entering:'||l_proc, 5);
19   --
20   Return (nvl(g_api_dml, false));
21   --
22   hr_utility.set_location(' Leaving:'||l_proc, 10);
23 End return_api_dml_status;
24 --
25 -- ----------------------------------------------------------------------------
26 -- |---------------------------< constraint_error >---------------------------|
27 -- ----------------------------------------------------------------------------
28 Procedure constraint_error
29             (p_constraint_name in all_constraints.constraint_name%TYPE) Is
30 --
31   l_proc 	varchar2(72) := g_package||'constraint_error';
32 --
33 Begin
34   hr_utility.set_location('Entering:'||l_proc, 5);
35   --
36   If (p_constraint_name = 'GHR_EVENT_HISTORY_FK') Then
37     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
38     hr_utility.set_message_token('PROCEDURE', l_proc);
39     hr_utility.set_message_token('STEP','5');
40     hr_utility.raise_error;
41   ElsIf (p_constraint_name = 'GHR_EVENT_HISTORY_PK') Then
42     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
43     hr_utility.set_message_token('PROCEDURE', l_proc);
44     hr_utility.set_message_token('STEP','10');
45     hr_utility.raise_error;
46   Else
47     hr_utility.set_message(801, 'HR_7877_API_INVALID_CONSTRAINT');
48     hr_utility.set_message_token('PROCEDURE', l_proc);
49     hr_utility.set_message_token('CONSTRAINT_NAME', p_constraint_name);
50     hr_utility.raise_error;
51   End If;
52   --
53   hr_utility.set_location(' Leaving:'||l_proc, 10);
54 End constraint_error;
55 --
56 -- ----------------------------------------------------------------------------
57 -- |-----------------------------< api_updating >-----------------------------|
58 -- ----------------------------------------------------------------------------
59 Function api_updating
60   (
61   p_event_history_id                   in number,
62   p_object_version_number              in number
63   )      Return Boolean Is
64 --
65   --
66   -- Cursor selects the 'current' row from the HR Schema
67   --
68   Cursor C_Sel1 is
69     select
70 		event_history_id,
71 	event_id,
72 	table_name,
73 	record_id,
74 	start_date,
75 	end_date,
76 	comments,
77 	object_version_number
78     from	ghr_event_history
79     where	event_history_id = p_event_history_id;
80 --
81   l_proc	varchar2(72)	:= g_package||'api_updating';
82   l_fct_ret	boolean;
83 --
84 Begin
85   hr_utility.set_location('Entering:'||l_proc, 5);
86   --
87   If (
88 	p_event_history_id is null and
89 	p_object_version_number is null
90      ) Then
91     --
92     -- One of the primary key arguments is null therefore we must
93     -- set the returning function value to false
94     --
95     l_fct_ret := false;
96   Else
97     If (
98 	p_event_history_id = g_old_rec.event_history_id and
99 	p_object_version_number = g_old_rec.object_version_number
100        ) Then
101       hr_utility.set_location(l_proc, 10);
102       --
103       -- The g_old_rec is current therefore we must
104       -- set the returning function to true
105       --
106       l_fct_ret := true;
107     Else
108       --
109       -- Select the current row into g_old_rec
110       --
111       Open C_Sel1;
112       Fetch C_Sel1 Into g_old_rec;
113       If C_Sel1%notfound Then
114         Close C_Sel1;
115         --
116         -- The primary key is invalid therefore we must error
117         --
118         hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
119         hr_utility.raise_error;
120       End If;
121       Close C_Sel1;
122       If (p_object_version_number <> g_old_rec.object_version_number) Then
123         hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
124         hr_utility.raise_error;
125       End If;
126       hr_utility.set_location(l_proc, 15);
127       l_fct_ret := true;
128     End If;
129   End If;
130   hr_utility.set_location(' Leaving:'||l_proc, 20);
131   Return (l_fct_ret);
132 --
133 End api_updating;
134 --
135 -- ----------------------------------------------------------------------------
136 -- |---------------------------------< lck >----------------------------------|
137 -- ----------------------------------------------------------------------------
138 Procedure lck
139   (
140   p_event_history_id                   in number,
141   p_object_version_number              in number
142   ) is
143 --
144 -- Cursor selects the 'current' row from the HR Schema
145 --
146   Cursor C_Sel1 is
147     select 	event_history_id,
148 	event_id,
149 	table_name,
150 	record_id,
151 	start_date,
152 	end_date,
153 	comments,
154 	object_version_number
155     from	ghr_event_history
156     where	event_history_id = p_event_history_id
157     for	update nowait;
158 --
159   l_proc	varchar2(72) := g_package||'lck';
160 --
161 Begin
162   hr_utility.set_location('Entering:'||l_proc, 5);
163   --
164   -- Add any mandatory argument checking here:
165   -- Example:
166   -- hr_api.mandatory_arg_error
167   --   (p_api_name       => l_proc,
168   --    p_argument       => 'object_version_number',
169   --    p_argument_value => p_object_version_number);
170   --
171   Open  C_Sel1;
172   Fetch C_Sel1 Into g_old_rec;
173   If C_Sel1%notfound then
174     Close C_Sel1;
175     --
176     -- The primary key is invalid therefore we must error
177     --
178     hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
179     hr_utility.raise_error;
180   End If;
181   Close C_Sel1;
182   If (p_object_version_number <> g_old_rec.object_version_number) Then
183         hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
184         hr_utility.raise_error;
185       End If;
186 --
187   hr_utility.set_location(' Leaving:'||l_proc, 10);
188 --
189 -- We need to trap the ORA LOCK exception
190 --
191 Exception
192   When HR_Api.Object_Locked then
193     --
194     -- The object is locked therefore we need to supply a meaningful
195     -- error message.
196     --
197     hr_utility.set_message(801, 'HR_7165_OBJECT_LOCKED');
198     hr_utility.set_message_token('TABLE_NAME', 'ghr_event_history');
199     hr_utility.raise_error;
200 End lck;
201 --
202 -- ----------------------------------------------------------------------------
203 -- |-----------------------------< convert_args >-----------------------------|
204 -- ----------------------------------------------------------------------------
205 Function convert_args
206 	(
207 	p_event_history_id              in number,
208 	p_event_id                      in number,
209 	p_table_name                    in varchar2,
210 	p_record_id                     in number,
211 	p_start_date                    in date,
212 	p_end_date                      in date,
213 	p_comments                      in varchar2,
214 	p_object_version_number         in number
215 	)
216 	Return g_rec_type is
217 --
218   l_rec	  g_rec_type;
219   l_proc  varchar2(72) := g_package||'convert_args';
220 --
221 Begin
222   --
223   hr_utility.set_location('Entering:'||l_proc, 5);
224   --
225   -- Convert arguments into local l_rec structure.
226   --
227   l_rec.event_history_id                 := p_event_history_id;
228   l_rec.event_id                         := p_event_id;
229   l_rec.table_name                       := p_table_name;
230   l_rec.record_id                        := p_record_id;
231   l_rec.start_date                       := p_start_date;
232   l_rec.end_date                         := p_end_date;
233   l_rec.comments                         := p_comments;
234   l_rec.object_version_number            := p_object_version_number;
235   --
236   -- Return the plsql record structure.
237   --
238   hr_utility.set_location(' Leaving:'||l_proc, 10);
239   Return(l_rec);
240 --
241 End convert_args;
242 --
243 end ghr_evh_shd;