DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_CET_SHD

Source


1 Package Body pqh_cet_shd as
2 /* $Header: pqcetrhi.pkb 120.2 2005/10/01 10:56:44 scnair noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  pqh_cet_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_COPY_ENTITY_TXNS_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_COPY_ENTITY_TXNS_FK2') 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_COPY_ENTITY_TXNS_PK') Then
32     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
33     hr_utility.set_message_token('PROCEDURE', l_proc);
34     hr_utility.set_message_token('STEP','15');
35     hr_utility.raise_error;
36   ElsIf (p_constraint_name = 'PQH_COMPLETED_TARGET') Then
37     hr_utility.set_message(8302, 'PQH_COMPLETED_TARGET');
38     hr_utility.raise_error;
39   ElsIf (p_constraint_name = 'PQH_COPY_ENTITY_TXNS_UK') Then
40     hr_utility.set_message(8302, 'PQH_GEN_UNQUE_NAME');
41     hr_utility.raise_error;
42   Else
43     hr_utility.set_message(801, 'HR_7877_API_INVALID_CONSTRAINT');
44     hr_utility.set_message_token('PROCEDURE', l_proc);
45     hr_utility.set_message_token('CONSTRAINT_NAME', p_constraint_name);
46     hr_utility.raise_error;
47   End If;
48   --
49   hr_utility.set_location(' Leaving:'||l_proc, 10);
50 End constraint_error;
51 --
52 -- ----------------------------------------------------------------------------
53 -- |-----------------------------< api_updating >-----------------------------|
54 -- ----------------------------------------------------------------------------
55 Function api_updating
56   (
57   p_copy_entity_txn_id                 in number,
58   p_object_version_number              in number
59   )      Return Boolean Is
60 --
61   --
62   -- Cursor selects the 'current' row from the HR Schema
63   --
64   Cursor C_Sel1 is
65     select
66 		copy_entity_txn_id,
67 	transaction_category_id,
68 	txn_category_attribute_id,
69 	context_business_group_id,
70 	datetrack_mode,
71 	context         ,
72         action_date ,
73         src_effective_date,
74 	number_of_copies,
75 	display_name,
76 	replacement_type_cd,
77 	start_with,
78 	increment_by,
79 	status,
80 	object_version_number
81     from	pqh_copy_entity_txns
82     where	copy_entity_txn_id = p_copy_entity_txn_id;
83 --
84   l_proc	varchar2(72)	:= g_package||'api_updating';
85   l_fct_ret	boolean;
86 --
87 Begin
88   hr_utility.set_location('Entering:'||l_proc, 5);
89   --
90   If (
91 	p_copy_entity_txn_id is null and
92 	p_object_version_number is null
93      ) Then
94     --
95     -- One of the primary key arguments is null therefore we must
96     -- set the returning function value to false
97     --
98     l_fct_ret := false;
99   Else
100     If (
101 	p_copy_entity_txn_id = g_old_rec.copy_entity_txn_id and
102 	p_object_version_number = g_old_rec.object_version_number
103        ) Then
104       hr_utility.set_location(l_proc, 10);
105       --
106       -- The g_old_rec is current therefore we must
107       -- set the returning function to true
108       --
109       l_fct_ret := true;
110     Else
111       --
112       -- Select the current row into g_old_rec
113       --
114       Open C_Sel1;
115       Fetch C_Sel1 Into g_old_rec;
116       If C_Sel1%notfound Then
117         Close C_Sel1;
118         --
119         -- The primary key is invalid therefore we must error
120         --
121         hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
122         hr_utility.raise_error;
123       End If;
124       Close C_Sel1;
125       If (p_object_version_number <> g_old_rec.object_version_number) Then
126         hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
127         hr_utility.raise_error;
128       End If;
129       hr_utility.set_location(l_proc, 15);
130       l_fct_ret := true;
131     End If;
132   End If;
133   hr_utility.set_location(' Leaving:'||l_proc, 20);
134   Return (l_fct_ret);
135 --
136 End api_updating;
137 --
138 -- ----------------------------------------------------------------------------
139 -- |---------------------------------< lck >----------------------------------|
140 -- ----------------------------------------------------------------------------
141 Procedure lck
142   (
143   p_copy_entity_txn_id                 in number,
144   p_object_version_number              in number
145   ) is
146 --
147 -- Cursor selects the 'current' row from the HR Schema
148 --
149   Cursor C_Sel1 is
150     select 	copy_entity_txn_id,
151 	transaction_category_id,
152 	txn_category_attribute_id,
153 	context_business_group_id,
154 	datetrack_mode,
155 	context         ,
156         action_date ,
157         src_effective_date,
158 	number_of_copies ,
159 	display_name,
160 	replacement_type_cd,
161 	start_with,
162 	increment_by,
163 	status,
164 	object_version_number
165     from	pqh_copy_entity_txns
166     where	copy_entity_txn_id = p_copy_entity_txn_id
167     for	update nowait;
168 --
169   l_proc	varchar2(72) := g_package||'lck';
170 --
171 Begin
172   hr_utility.set_location('Entering:'||l_proc, 5);
173   --
174   -- Add any mandatory argument checking here:
175   -- Example:
176    hr_api.mandatory_arg_error
177      (p_api_name       => l_proc,
178       p_argument       => 'object_version_number',
179       p_argument_value => p_object_version_number);
180   --
181   Open  C_Sel1;
182   Fetch C_Sel1 Into g_old_rec;
183   If C_Sel1%notfound then
184     Close C_Sel1;
185     --
186     -- The primary key is invalid therefore we must error
187     --
188     hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
189     hr_utility.raise_error;
190   End If;
191   Close C_Sel1;
192   If (p_object_version_number <> g_old_rec.object_version_number) Then
193         hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
194         hr_utility.raise_error;
195       End If;
196 --
197   hr_utility.set_location(' Leaving:'||l_proc, 10);
198 --
199 -- We need to trap the ORA LOCK exception
200 --
201 Exception
202   When HR_Api.Object_Locked then
203     --
204     -- The object is locked therefore we need to supply a meaningful
205     -- error message.
206     --
207     hr_utility.set_message(801, 'HR_7165_OBJECT_LOCKED');
208     hr_utility.set_message_token('TABLE_NAME', 'pqh_copy_entity_txns');
209     hr_utility.raise_error;
210 End lck;
211 --
212 -- ----------------------------------------------------------------------------
213 -- |-----------------------------< convert_args >-----------------------------|
214 -- ----------------------------------------------------------------------------
215 Function convert_args
216 	(
217 	p_copy_entity_txn_id            in number,
218 	p_transaction_category_id       in number,
219 	p_txn_category_attribute_id     in number,
220      p_context_business_group_id      in  number,
221      p_datetrack_mode                 in  varchar2,
222 	p_context                       in varchar2,
223         p_action_date                   in date,
224         p_src_effective_date            in date,
225 	p_number_of_copies              in number,
226 	p_display_name                  in varchar2,
227 	p_replacement_type_cd           in varchar2,
228 	p_start_with                    in varchar2,
229 	p_increment_by                  in number,
230 	p_status                        in varchar2,
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.copy_entity_txn_id               := p_copy_entity_txn_id;
245   l_rec.transaction_category_id          := p_transaction_category_id;
246   l_rec.txn_category_attribute_id        := p_txn_category_attribute_id;
247   l_rec.context_business_group_id        := p_context_business_group_id;
248   l_rec.datetrack_mode                   := p_datetrack_mode;
249   l_rec.context                          := p_context         ;
250   l_rec.action_date                      := p_action_date ;
251   l_rec.src_effective_date               := p_src_effective_date ;
252   l_rec.number_of_copies                 := p_number_of_copies ;
253   l_rec.display_name                     := p_display_name;
254   l_rec.replacement_type_cd              := p_replacement_type_cd;
255   l_rec.start_with                       := p_start_with;
256   l_rec.increment_by                     := p_increment_by;
257   l_rec.status                           := p_status;
258   l_rec.object_version_number            := p_object_version_number;
259   --
260   -- Return the plsql record structure.
261   --
262   hr_utility.set_location(' Leaving:'||l_proc, 10);
263   Return(l_rec);
264 --
265 End convert_args;
266 --
267 end pqh_cet_shd;