1 Package ame_apu_shd as
2 /* $Header: amapurhi.pkh 120.0 2005/09/02 03:50 mbocutt noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Global Record Type Specification |
6 -- ----------------------------------------------------------------------------
7 --
8 Type g_rec_type Is Record
9 (approver_type_id number(15)
10 ,action_type_id number(15)
11 ,start_date date
12 ,end_date date
13 ,object_version_number number(9)
14 );
15 --
16 -- ----------------------------------------------------------------------------
17 -- | Global Definitions - Internal Development Use Only |
18 -- ----------------------------------------------------------------------------
19 --
20 g_old_rec g_rec_type; -- Global record definition
21 -- Global table name
22 g_tab_nam constant varchar2(30) := 'AME_APPROVER_TYPE_USAGES';
23 --
24 -- ----------------------------------------------------------------------------
25 -- |---------------------------< constraint_error >---------------------------|
26 -- ----------------------------------------------------------------------------
27 -- {Start Of Comments}
28 --
29 -- Description:
30 -- This procedure is called when a constraint has been violated (i.e.
31 -- The exception hr_api.check_integrity_violated,
32 -- hr_api.parent_integrity_violated, hr_api.child_integrity_violated or
33 -- hr_api.unique_integrity_violated has been raised).
34 -- The exceptions can only be raised as follows:
35 -- 1) A check constraint can only be violated during an INSERT or UPDATE
36 -- dml operation.
37 -- 2) A parent integrity constraint can only be violated during an
38 -- INSERT or UPDATE dml operation.
39 -- 3) A child integrity constraint can only be violated during an
40 -- DELETE dml operation.
41 -- 4) A unique integrity constraint can only be violated during INSERT or
42 -- UPDATE dml operation.
43 --
44 -- Prerequisites:
45 -- 1) Either hr_api.check_integrity_violated,
46 -- hr_api.parent_integrity_violated, hr_api.child_integrity_violated or
47 -- hr_api.unique_integrity_violated has been raised with the subsequent
48 -- stripping of the constraint name from the generated error message
49 -- text.
50 -- 2) Standalone validation test which corresponds with a constraint error.
51 --
52 -- In Parameter:
53 -- p_constraint_name is in upper format and is just the constraint name
54 -- (e.g. not prefixed by brackets, schema owner etc).
55 --
56 -- Post Success:
57 -- Development dependant.
58 --
59 -- Post Failure:
60 -- Developement dependant.
61 --
62 -- Developer Implementation Notes:
63 -- For each constraint being checked the hr system package failure message
64 -- has been generated as a template only. These system error messages should
65 -- be modified as required (i.e. change the system failure message to a user
66 -- friendly defined error message).
67 --
68 -- Access Status:
69 -- Internal Development Use Only.
70 --
71 -- {End Of Comments}
72 -- ----------------------------------------------------------------------------
73 Procedure constraint_error
74 (p_constraint_name in all_constraints.constraint_name%TYPE);
75 --
76 -- ----------------------------------------------------------------------------
77 -- |-----------------------------< api_updating >-----------------------------|
78 -- ----------------------------------------------------------------------------
79 -- {Start Of Comments}
80 --
81 -- Description:
82 -- This function is used to populate the g_old_rec record with the
83 -- current row from the database for the specified primary key
84 -- provided that the primary key exists and is valid and does not
85 -- already match the current g_old_rec. The function will always return
86 -- a TRUE value if the g_old_rec is populated with the current row.
87 -- A FALSE value will be returned if all of the primary key arguments
88 -- are null.
89 --
90 -- Prerequisites:
91 -- None.
92 --
93 -- In Parameters:
94 --
95 -- Post Success:
96 -- A value of TRUE will be returned indiciating that the g_old_rec
97 -- is current.
98 -- A value of FALSE will be returned if all of the primary key arguments
99 -- have a null value (this indicates that the row has not be inserted into
100 -- the Schema), and therefore could never have a corresponding row.
101 --
102 -- Post Failure:
103 -- A failure can only occur under two circumstances:
104 -- 1) The primary key is invalid (i.e. a row does not exist for the
105 -- specified primary key values).
106 -- 2) If an object_version_number exists but is NOT the same as the current
107 -- g_old_rec value.
108 --
109 -- Developer Implementation Notes:
110 -- None.
111 --
112 -- Access Status:
113 -- Internal Development Use Only.
114 --
115 -- {End Of Comments}
116 -- ----------------------------------------------------------------------------
117 Function api_updating
118 (p_effective_date in date
119 ,p_approver_type_id in number
120 ,p_action_type_id in number
121 ,p_object_version_number in number
122 ) Return Boolean;
123 --
124 -- ----------------------------------------------------------------------------
125 -- |-----------------------< upd_end_date >-------------------------|
126 -- ----------------------------------------------------------------------------
127 -- {Start Of Comments}
128 --
129 -- Description:
130 -- This procedure will update the specified datetrack row with the
131 -- specified new effective end date. The object version number is also
132 -- set to the next object version number. DateTrack modes which call
133 -- this procedure are: UPDATE, UPDATE_CHANGE_INSERT,
134 -- UPDATE_OVERRIDE, DELETE, FUTURE_CHANGE and DELETE_NEXT_CHANGE.
135 -- This is an internal datetrack maintenance procedure which should
136 -- not be modified in anyway.
137 --
138 -- Prerequisites:
139 -- None.
140 --
141 -- In Parameters:
142 -- p_new_end_date
143 -- Specifies the new effective end date which will be set for the
144 -- row as of the effective date.
145 -- p_base_key_value
146 -- Specifies the primary key value for this datetrack entity.
147 -- (E.g. For this entity the assignment of the argument would be:
148 -- p_base_key_value = :approver_type_id).
149 --
150 -- Post Success:
151 -- The specified row will be updated with the new effective end date and
152 -- object_version_number.
153 --
154 -- Post Failure:
155 -- Failure might occur if for the specified effective date and primary key
156 -- value a row doesn't exist.
157 --
158 -- Developer Implementation Notes:
159 -- This is an internal datetrack maintenance procedure which should
160 -- not be modified in anyway.
161 --
162 -- Access Status:
163 -- Internal Row Handler Use Only.
164 --
165 -- {End Of Comments}
166 -- ----------------------------------------------------------------------------
167 Procedure upd_end_date
168 (p_effective_date in date
169 ,p_approver_type_id in number
170 ,p_action_type_id in number
171 ,p_new_end_date in date
172 ,p_validation_start_date in date
173 ,p_validation_end_date in date
174 ,p_object_version_number out nocopy number
175 );
176 --
177 -- ----------------------------------------------------------------------------
178 -- |---------------------------------< lck >----------------------------------|
179 -- ----------------------------------------------------------------------------
180 -- {Start Of Comments}
181 --
182 -- Description:
183 -- The Lck process for datetrack is complicated and comprises of the
184 -- following processing
185 -- The processing steps are as follows:
186 -- 1) The row to be updated or deleted must be locked.
187 -- By locking this row, the g_old_rec record data type is populated.
188 -- 2) If a comment exists the text is selected from hr_comments.
189 -- 3) The datetrack mode is then validated to ensure the operation is
190 -- valid. If the mode is valid the validation start and end dates for
191 -- the mode will be derived and returned. Any required locking is
192 -- completed when the datetrack mode is validated.
193 --
194 -- Prerequisites:
195 -- When attempting to call the lck procedure the object version number,
196 -- primary key, effective date and datetrack mode must be specified.
197 --
198 -- In Parameters:
199 -- p_effective_date
200 -- Specifies the date of the datetrack update operation.
201 -- p_datetrack_mode
202 -- Determines the datetrack update or delete mode.
203 --
204 -- Post Success:
205 -- On successful completion of the Lck process the row to be updated or
206 -- deleted will be locked and selected into the global data structure
207 -- g_old_rec.
208 --
209 -- Post Failure:
210 -- The Lck process can fail for three reasons:
211 -- 1) When attempting to lock the row the row could already be locked by
212 -- another user. This will raise the HR_Api.Object_Locked exception.
213 -- 2) The row which is required to be locked doesn't exist in the HR Schema.
214 -- This error is trapped and reported using the message name
215 -- 'HR_7220_INVALID_PRIMARY_KEY'.
216 -- 3) The row although existing in the HR Schema has a different object
217 -- version number than the object version number specified.
218 -- This error is trapped and reported using the message name
219 -- 'HR_7155_OBJECT_INVALID'.
220 --
221 -- Developer Implementation Notes:
222 -- None.
223 --
224 -- Access Status:
225 -- Internal Development Use Only.
226 --
227 -- {End Of Comments}
228 -- ----------------------------------------------------------------------------
229 Procedure lck
230 (p_effective_date in date
231 ,p_datetrack_mode in varchar2
232 ,p_approver_type_id in number
233 ,p_action_type_id in number
234 ,p_object_version_number in number
235 ,p_validation_start_date out nocopy date
236 ,p_validation_end_date out nocopy date
237 );
238 --
239 -- ----------------------------------------------------------------------------
240 -- |-----------------------------< convert_args >-----------------------------|
241 -- ----------------------------------------------------------------------------
242 -- {Start Of Comments}
243 --
244 -- Description:
245 -- This function is used to turn attribute parameters into the record
246 -- structure parameter g_rec_type.
247 --
248 -- Prerequisites:
249 -- This is a private function and can only be called from the ins or upd
250 -- attribute processes.
251 --
252 -- In Parameters:
253 --
254 -- Post Success:
255 -- A returning record structure will be returned.
256 --
257 -- Post Failure:
258 -- No direct error handling is required within this function. Any possible
259 -- errors within this function will be a PL/SQL value error due to
260 -- conversion of datatypes or data lengths.
261 --
262 -- Developer Implementation Notes:
263 -- None.
264 --
265 -- Access Status:
266 -- Internal Row Handler Use Only.
267 --
268 -- {End Of Comments}
269 -- ----------------------------------------------------------------------------
270 Function convert_args
271 (p_approver_type_id in number
272 ,p_action_type_id in number
273 ,p_start_date in date
274 ,p_end_date in date
275 ,p_object_version_number in number
276 )
277 Return g_rec_type;
278 --
279 -- ----------------------------------------------------------------------------
280 -- |-----------------------------< get_object_version_number >----------------|
281 -- ----------------------------------------------------------------------------
282 -- {Start Of Comments}
283 --
284 -- Description:
285 -- This function is used to get the next object version number to be used
286 -- within datetrack for an insert or update dml operation. The returned
287 -- object version number will be determined by taking the maximum
288 -- object version number for the datetracked rows and then incrementing by 1.
289 --
290 --
291 -- Prerequisites:
292 -- This is a private function and can only be called from the ins or upd
293 -- attribute processes.
294 --
295 -- In Parameters:
296 --
297 --
298 -- Post Success:
299 --
300 --
301 -- Post Failure:
302 --
303 --
304 --
305 --
306 -- Developer Implementation Notes:
307 -- None.
308 --
309 -- Access Status:
310 -- Internal Row Handler Use Only.
311 --
312 -- {End Of Comments}
313 -- ----------------------------------------------------------------------------
314 Function get_object_version_number
315 (p_approver_type_id in number
316 ,p_action_type_id in number
317 )
318 Return number;
319 --
320 --
321 end ame_apu_shd;