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