DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_WEL_SHD

Source


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