DBA Data[Home] [Help]

PACKAGE BODY: APPS.GHR_CAD_SHD

Source


1 Package Body ghr_cad_shd as
2 /* $Header: ghcadrhi.pkb 115.4 2003/01/30 19:24:51 asubrahm noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  ghr_cad_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 = 'GHR_COMPL_ADRS_FK1') 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 >-----------------------------|
37 -- ----------------------------------------------------------------------------
38 Function api_updating
39   (p_compl_adr_id                         in     number
40   ,p_object_version_number                in     number
41   )
42   Return Boolean Is
43   --
44   --
45   -- Cursor selects the 'current' row from the HR Schema
46   --
47   Cursor C_Sel1 is
48     select
49        compl_adr_id
50       ,complaint_id
51       ,stage
52       ,start_date
53       ,end_date
54       ,adr_resource
55       ,technique
56       ,outcome
57       ,adr_offered
58       ,date_accepted
59       ,object_version_number
60     from        ghr_compl_adrs
61     where       compl_adr_id = p_compl_adr_id;
62   --
63   l_fct_ret     boolean;
64   --
65 Begin
66   --
67   If (p_compl_adr_id is null and
68       p_object_version_number is null
69      ) Then
70     --
71     -- One of the primary key arguments is null therefore we must
72     -- set the returning function value to false
73     --
74     l_fct_ret := false;
75   Else
76     If (p_compl_adr_id
77         = ghr_cad_shd.g_old_rec.compl_adr_id and
78         p_object_version_number
79         = ghr_cad_shd.g_old_rec.object_version_number
80        ) Then
81       --
82       -- The g_old_rec is current therefore we must
83       -- set the returning function to true
84       --
85       l_fct_ret := true;
86     Else
87       --
88       -- Select the current row into g_old_rec
89       --
90       Open C_Sel1;
91       Fetch C_Sel1 Into ghr_cad_shd.g_old_rec;
92       If C_Sel1%notfound Then
93         Close C_Sel1;
94         --
95         -- The primary key is invalid therefore we must error
96         --
97         fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
98         fnd_message.raise_error;
99       End If;
100       Close C_Sel1;
101       If (p_object_version_number
102           <> ghr_cad_shd.g_old_rec.object_version_number) Then
103         fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
104         fnd_message.raise_error;
105       End If;
106       l_fct_ret := true;
107     End If;
108   End If;
109   Return (l_fct_ret);
110 --
111 End api_updating;
112 --
113 -- ----------------------------------------------------------------------------
114 -- |---------------------------------< lck >----------------------------------|
115 -- ----------------------------------------------------------------------------
116 Procedure lck
117   (p_compl_adr_id                         in     number
118   ,p_object_version_number                in     number
119   ) is
120 --
121 -- Cursor selects the 'current' row from the HR Schema
122 --
123   Cursor C_Sel1 is
124     select
125        compl_adr_id
126       ,complaint_id
127       ,stage
128       ,start_date
129       ,end_date
130       ,adr_resource
131       ,technique
132       ,outcome
133       ,adr_offered
134       ,date_accepted
135       ,object_version_number
136     from        ghr_compl_adrs
137     where       compl_adr_id = p_compl_adr_id
138     for update nowait;
139 --
140   l_proc        varchar2(72) := g_package||'lck';
141 --
142 Begin
143   hr_utility.set_location('Entering:'||l_proc, 5);
144   --
145   hr_api.mandatory_arg_error
146     (p_api_name           => l_proc
147     ,p_argument           => 'COMPL_ADR_ID'
148     ,p_argument_value     => p_compl_adr_id
149     );
150   hr_utility.set_location(l_proc,6);
151   hr_api.mandatory_arg_error
152     (p_api_name           => l_proc
153     ,p_argument           => 'OBJECT_VERSION_NUMBER'
154     ,p_argument_value     => p_object_version_number
155     );
156   --
157   Open  C_Sel1;
158   Fetch C_Sel1 Into ghr_cad_shd.g_old_rec;
159   If C_Sel1%notfound then
160     Close C_Sel1;
161     --
162     -- The primary key is invalid therefore we must error
163     --
164     fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
165     fnd_message.raise_error;
166   End If;
167   Close C_Sel1;
168   If (p_object_version_number
169       <> ghr_cad_shd.g_old_rec.object_version_number) Then
170         fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
171         fnd_message.raise_error;
172   End If;
173   --
174   hr_utility.set_location(' Leaving:'||l_proc, 10);
175   --
176   -- We need to trap the ORA LOCK exception
177   --
178 Exception
179   When HR_Api.Object_Locked then
180     --
181     -- The object is locked therefore we need to supply a meaningful
182     -- error message.
183     --
184     fnd_message.set_name('PAY', 'HR_7165_OBJECT_LOCKED');
185     fnd_message.set_token('TABLE_NAME', 'ghr_compl_adrs');
186     fnd_message.raise_error;
187 End lck;
188 --
189 -- ----------------------------------------------------------------------------
190 -- |-----------------------------< convert_args >-----------------------------|
191 -- ----------------------------------------------------------------------------
192 Function convert_args
193   (p_compl_adr_id                   in number
194   ,p_complaint_id                   in number
195   ,p_stage                          in varchar2
196   ,p_start_date                     in date
197   ,p_end_date                       in date
198   ,p_adr_resource                   in varchar2
199   ,p_technique                      in varchar2
200   ,p_outcome                        in varchar2
201   ,p_adr_offered                    in varchar2
202   ,p_date_accepted                  in date
203   ,p_object_version_number          in number
204   )
205   Return g_rec_type is
206 --
207   l_rec   g_rec_type;
208 --
209 Begin
210   --
211   -- Convert arguments into local l_rec structure.
212   --
213   l_rec.compl_adr_id                     := p_compl_adr_id;
214   l_rec.complaint_id                     := p_complaint_id;
215   l_rec.stage                            := p_stage;
216   l_rec.start_date                       := p_start_date;
217   l_rec.end_date                         := p_end_date;
218   l_rec.adr_resource                     := p_adr_resource;
219   l_rec.technique                        := p_technique;
220   l_rec.outcome                          := p_outcome;
221   l_rec.adr_offered                      := p_adr_offered;
222   l_rec.date_accepted                    := p_date_accepted;
223   l_rec.object_version_number            := p_object_version_number;
224   --
225   -- Return the plsql record structure.
226   --
227   Return(l_rec);
228 --
229 End convert_args;
230 --
231 end ghr_cad_shd;