DBA Data[Home] [Help]
Skip to content

PACKAGE BODY: APPS.PQH_WKS_SHD

Source


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