DBA Data[Home] [Help]

PACKAGE BODY: APPS.GHR_PRE_SHD

Source


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