DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_PAC_SHD

Source


1 Package Body hr_pac_shd as
2 /* $Header: hrpacrhi.pkb 115.2 99/07/17 05:36:19 porting ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  hr_pac_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 = 'HR_PAC_PAB_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 = 'HR_PAC_PAB_PAT_ARC') 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   ElsIf (p_constraint_name = 'HR_PAC_PAT_01_FK') Then
47     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
48     hr_utility.set_message_token('PROCEDURE', l_proc);
49     hr_utility.set_message_token('STEP','15');
50     hr_utility.raise_error;
51   ElsIf (p_constraint_name = 'HR_PAC_PAT_02_FK') Then
52     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
53     hr_utility.set_message_token('PROCEDURE', l_proc);
54     hr_utility.set_message_token('STEP','20');
55     hr_utility.raise_error;
56   ElsIf (p_constraint_name = 'HR_PAC_PAT_AVAILABILITY') Then
57     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
58     hr_utility.set_message_token('PROCEDURE', l_proc);
59     hr_utility.set_message_token('STEP','25');
60     hr_utility.raise_error;
61   ElsIf (p_constraint_name = 'HR_PAC_SEQUENCE_POSITIVE') Then
62     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
63     hr_utility.set_message_token('PROCEDURE', l_proc);
64     hr_utility.set_message_token('STEP','30');
65     hr_utility.raise_error;
66   Else
67     hr_utility.set_message(801, 'HR_7877_API_INVALID_CONSTRAINT');
68     hr_utility.set_message_token('PROCEDURE', l_proc);
69     hr_utility.set_message_token('CONSTRAINT_NAME', p_constraint_name);
70     hr_utility.raise_error;
71   End If;
72   --
73   hr_utility.set_location(' Leaving:'||l_proc, 10);
74 End constraint_error;
75 --
76 -- ----------------------------------------------------------------------------
77 -- |-----------------------------< api_updating >-----------------------------|
78 -- ----------------------------------------------------------------------------
79 Function api_updating
80   (
81   p_pattern_construction_id            in number,
82   p_object_version_number              in number
83   )      Return Boolean Is
84 --
85   --
86   -- Cursor selects the 'current' row from the HR Schema
87   --
88   Cursor C_Sel1 is
89     select
90 		pattern_construction_id,
91 	sequence_no,
92 	availability,
93 	pattern_id,
94 	pattern_bit_id,
95 	component_pattern_id,
96 	object_version_number
97     from	hr_pattern_constructions
98     where	pattern_construction_id = p_pattern_construction_id;
99 --
100   l_proc	varchar2(72)	:= g_package||'api_updating';
101   l_fct_ret	boolean;
102 --
103 Begin
104   hr_utility.set_location('Entering:'||l_proc, 5);
105   --
106   If (
107 	p_pattern_construction_id is null and
108 	p_object_version_number is null
109      ) Then
110     --
111     -- One of the primary key arguments is null therefore we must
112     -- set the returning function value to false
113     --
114     l_fct_ret := false;
115   Else
116     If (
117 	p_pattern_construction_id = g_old_rec.pattern_construction_id and
118 	p_object_version_number = g_old_rec.object_version_number
119        ) Then
120       hr_utility.set_location(l_proc, 10);
121       --
122       -- The g_old_rec is current therefore we must
123       -- set the returning function to true
124       --
125       l_fct_ret := true;
126     Else
127       --
128       -- Select the current row into g_old_rec
129       --
130       Open C_Sel1;
131       Fetch C_Sel1 Into g_old_rec;
132       If C_Sel1%notfound Then
133         Close C_Sel1;
134         --
135         -- The primary key is invalid therefore we must error
136         --
137         hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
138         hr_utility.raise_error;
139       End If;
140       Close C_Sel1;
141       If (p_object_version_number <> g_old_rec.object_version_number) Then
142         hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
143         hr_utility.raise_error;
144       End If;
145       hr_utility.set_location(l_proc, 15);
146       l_fct_ret := true;
147     End If;
148   End If;
149   hr_utility.set_location(' Leaving:'||l_proc, 20);
150   Return (l_fct_ret);
151 --
152 End api_updating;
153 --
154 -- ----------------------------------------------------------------------------
155 -- |---------------------------------< lck >----------------------------------|
156 -- ----------------------------------------------------------------------------
157 Procedure lck
158   (
159   p_pattern_construction_id            in number,
160   p_object_version_number              in number
161   ) is
162 --
163 -- Cursor selects the 'current' row from the HR Schema
164 --
165   Cursor C_Sel1 is
166     select 	pattern_construction_id,
167 	sequence_no,
168 	availability,
169 	pattern_id,
170 	pattern_bit_id,
171 	component_pattern_id,
172 	object_version_number
173     from	hr_pattern_constructions
174     where	pattern_construction_id = p_pattern_construction_id
175     for	update nowait;
176 --
177   l_proc	varchar2(72) := g_package||'lck';
178 --
179 Begin
180   hr_utility.set_location('Entering:'||l_proc, 5);
181   --
182   -- Add any mandatory argument checking here:
183   -- Example:
184   -- hr_api.mandatory_arg_error
185   --   (p_api_name       => l_proc,
186   --    p_argument       => 'object_version_number',
187   --    p_argument_value => p_object_version_number);
188   --
189   Open  C_Sel1;
190   Fetch C_Sel1 Into g_old_rec;
191   If C_Sel1%notfound then
192     Close C_Sel1;
193     --
194     -- The primary key is invalid therefore we must error
195     --
196     hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
197     hr_utility.raise_error;
198   End If;
199   Close C_Sel1;
200   If (p_object_version_number <> g_old_rec.object_version_number) Then
201         hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
202         hr_utility.raise_error;
203       End If;
204 --
205   hr_utility.set_location(' Leaving:'||l_proc, 10);
206 --
207 -- We need to trap the ORA LOCK exception
208 --
209 Exception
210   When HR_Api.Object_Locked then
211     --
212     -- The object is locked therefore we need to supply a meaningful
213     -- error message.
214     --
215     hr_utility.set_message(801, 'HR_7165_OBJECT_LOCKED');
216     hr_utility.set_message_token('TABLE_NAME', 'hr_pattern_constructions');
217     hr_utility.raise_error;
218 End lck;
219 --
220 -- ----------------------------------------------------------------------------
221 -- |-----------------------------< convert_args >-----------------------------|
222 -- ----------------------------------------------------------------------------
223 Function convert_args
224 	(
225 	p_pattern_construction_id       in number,
226 	p_sequence_no                   in number,
227 	p_availability                  in varchar2,
228 	p_pattern_id                    in number,
229 	p_pattern_bit_id                in number,
230 	p_component_pattern_id          in number,
231 	p_object_version_number         in number
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.pattern_construction_id          := p_pattern_construction_id;
245   l_rec.sequence_no                      := p_sequence_no;
246   l_rec.availability                     := p_availability;
247   l_rec.pattern_id                       := p_pattern_id;
248   l_rec.pattern_bit_id                   := p_pattern_bit_id;
249   l_rec.component_pattern_id             := p_component_pattern_id;
250   l_rec.object_version_number            := p_object_version_number;
251   --
252   -- Return the plsql record structure.
253   --
254   hr_utility.set_location(' Leaving:'||l_proc, 10);
255   Return(l_rec);
256 --
257 End convert_args;
258 --
259 end hr_pac_shd;