1 Package ame_apg_shd as
2 /* $Header: amapgrhi.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 (approval_group_id number
10 ,name varchar2(50)
11 ,start_date date
12 ,end_date date
13 ,description varchar2(100)
14 ,query_string varchar2(4000)
15 ,is_static varchar2(9) -- Increased length
16 ,security_group_id number(15)
17 ,object_version_number number(9)
18 );
19 --
20 -- ----------------------------------------------------------------------------
21 -- | Global Definitions - Internal Development Use Only |
22 -- ----------------------------------------------------------------------------
23 --
24 g_old_rec g_rec_type; -- Global record definition
25 -- Global table name
26 g_tab_nam constant varchar2(30) := 'AME_APPROVAL_GROUPS';
27 --
28 -- ----------------------------------------------------------------------------
29 -- |---------------------------< constraint_error >---------------------------|
30 -- ----------------------------------------------------------------------------
31 -- {Start Of Comments}
32 --
33 -- Description:
34 -- This procedure is called when a constraint has been violated (i.e.
35 -- The exception hr_api.check_integrity_violated,
36 -- hr_api.parent_integrity_violated, hr_api.child_integrity_violated or
37 -- hr_api.unique_integrity_violated has been raised).
38 -- The exceptions can only be raised as follows:
39 -- 1) A check constraint can only be violated during an INSERT or UPDATE
40 -- dml operation.
41 -- 2) A parent integrity constraint can only be violated during an
42 -- INSERT or UPDATE dml operation.
43 -- 3) A child integrity constraint can only be violated during an
44 -- DELETE dml operation.
45 -- 4) A unique integrity constraint can only be violated during INSERT or
46 -- UPDATE dml operation.
47 --
48 -- Prerequisites:
49 -- 1) Either hr_api.check_integrity_violated,
50 -- hr_api.parent_integrity_violated, hr_api.child_integrity_violated or
51 -- hr_api.unique_integrity_violated has been raised with the subsequent
52 -- stripping of the constraint name from the generated error message
53 -- text.
54 -- 2) Standalone validation test which corresponds with a constraint error.
55 --
56 -- In Parameter:
57 -- p_constraint_name is in upper format and is just the constraint name
58 -- (e.g. not prefixed by brackets, schema owner etc).
59 --
60 -- Post Success:
61 -- Development dependant.
62 --
63 -- Post Failure:
64 -- Developement dependant.
65 --
66 -- Developer Implementation Notes:
67 -- For each constraint being checked the hr system package failure message
68 -- has been generated as a template only. These system error messages should
69 -- be modified as required (i.e. change the system failure message to a user
70 -- friendly defined error message).
71 --
72 -- Access Status:
73 -- Internal Development Use Only.
74 --
75 -- {End Of Comments}
76 -- ----------------------------------------------------------------------------
77 Procedure constraint_error
78 (p_constraint_name in all_constraints.constraint_name%TYPE);
79 --
80 -- ----------------------------------------------------------------------------
81 -- |-----------------------------< api_updating >-----------------------------|
82 -- ----------------------------------------------------------------------------
83 -- {Start Of Comments}
84 --
85 -- Description:
86 -- This function is used to populate the g_old_rec record with the
87 -- current row from the database for the specified primary key
88 -- provided that the primary key exists and is valid and does not
89 -- already match the current g_old_rec. The function will always return
90 -- a TRUE value if the g_old_rec is populated with the current row.
91 -- A FALSE value will be returned if all of the primary key arguments
92 -- are null.
93 --
94 -- Prerequisites:
95 -- None.
96 --
97 -- In Parameters:
98 --
99 -- Post Success:
100 -- A value of TRUE will be returned indiciating that the g_old_rec
101 -- is current.
102 -- A value of FALSE will be returned if all of the primary key arguments
103 -- have a null value (this indicates that the row has not be inserted into
104 -- the Schema), and therefore could never have a corresponding row.
105 --
106 -- Post Failure:
107 -- A failure can only occur under two circumstances:
108 -- 1) The primary key is invalid (i.e. a row does not exist for the
109 -- specified primary key values).
110 -- 2) If an object_version_number exists but is NOT the same as the current
111 -- g_old_rec value.
112 --
113 -- Developer Implementation Notes:
114 -- None.
115 --
116 -- Access Status:
117 -- Internal Development Use Only.
118 --
119 -- {End Of Comments}
120 -- ----------------------------------------------------------------------------
121 Function api_updating
122 (p_effective_date in date
123 ,p_approval_group_id in number
124 ,p_object_version_number in number
125 ) Return Boolean;
126 --
127 -- ----------------------------------------------------------------------------
128 -- |----------------------------< upd_end_date >------------------------------|
129 -- ----------------------------------------------------------------------------
130 -- {Start Of Comments}
131 --
132 -- Description:
133 -- This procedure will update the specified datetrack row with the
134 -- specified new effective end date. The object version number is also
135 -- set to the next object version number. DateTrack modes which call
136 -- this procedure are: UPDATE, UPDATE_CHANGE_INSERT,
137 -- UPDATE_OVERRIDE, DELETE, FUTURE_CHANGE and DELETE_NEXT_CHANGE.
138 -- This is an internal datetrack maintenance procedure which should
139 -- not be modified in anyway.
140 --
141 -- Prerequisites:
142 -- None.
143 --
144 -- In Parameters:
145 -- p_new_effective_end_date
146 -- Specifies the new effective end date which will be set for the
147 -- row as of the effective date.
148 -- p_base_key_value
149 -- Specifies the primary key value for this datetrack entity.
150 -- (E.g. For this entity the assignment of the argument would be:
154 -- The specified row will be updated with the new effective end date and
151 -- p_base_key_value = :approval_group_id).
152 --
153 -- Post Success:
155 -- object_version_number.
156 --
157 -- Post Failure:
158 -- Failure might occur if for the specified effective date and primary key
159 -- value a row doesn't exist.
160 --
161 -- Developer Implementation Notes:
162 -- This is an internal datetrack maintenance procedure which should
163 -- not be modified in anyway.
164 --
165 -- Access Status:
166 -- Internal Row Handler Use Only.
167 --
168 -- {End Of Comments}
169 -- ----------------------------------------------------------------------------
170 Procedure upd_end_date
171 (p_effective_date in date
172 ,p_approval_group_id in number
173 ,p_new_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_approval_group_id in number
233 ,p_object_version_number in number
234 ,p_validation_start_date out nocopy date
235 ,p_validation_end_date out nocopy date
236 );
237 --
238 -- ----------------------------------------------------------------------------
239 -- |-----------------------------< convert_args >-----------------------------|
240 -- ----------------------------------------------------------------------------
241 -- {Start Of Comments}
242 --
243 -- Description:
244 -- This function is used to turn attribute parameters into the record
245 -- structure parameter g_rec_type.
246 --
250 --
247 -- Prerequisites:
248 -- This is a private function and can only be called from the ins or upd
249 -- attribute processes.
251 -- In Parameters:
252 --
253 -- Post Success:
254 -- A returning record structure will be returned.
255 --
256 -- Post Failure:
257 -- No direct error handling is required within this function. Any possible
258 -- errors within this function will be a PL/SQL value error due to
259 -- conversion of datatypes or data lengths.
260 --
261 -- Developer Implementation Notes:
262 -- None.
263 --
264 -- Access Status:
265 -- Internal Row Handler Use Only.
266 --
267 -- {End Of Comments}
268 -- ----------------------------------------------------------------------------
269 Function convert_args
270 (p_approval_group_id in number
271 ,p_name in varchar2
272 ,p_start_date in date
273 ,p_end_date in date
274 ,p_description in varchar2
275 ,p_query_string in varchar2
276 ,p_is_static in varchar2
277 ,p_security_group_id in number
278 ,p_object_version_number in number
279 )
280 Return g_rec_type;
281 --
282 -- ----------------------------------------------------------------------------
283 -- |-----------------------------< get_object_version_number >----------------|
284 -- ----------------------------------------------------------------------------
285 -- {Start Of Comments}
286 --
287 -- Description:
288 -- This function is used to get the next object version number to be used
289 -- within datetrack for an insert or update dml operation. The returned
290 -- object version number will be determined by taking the maximum
291 -- object version number for the datetracked rows and then incrementing by 1.
292 --
293 --
294 -- Prerequisites:
295 -- This is a private function and can only be called from the ins or upd
296 -- attribute processes.
297 --
298 -- In Parameters:
299 --
300 --
301 -- Post Success:
302 --
303 --
304 -- Post Failure:
305 --
306 --
307 --
308 --
309 -- Developer Implementation Notes:
310 -- None.
311 --
312 -- Access Status:
313 -- Internal Row Handler Use Only.
314 --
315 -- {End Of Comments}
316 -- ----------------------------------------------------------------------------
317 Function get_object_version_number
318 (p_approval_group_id in number
319 )
320 Return number;
321 --
322 -- ----------------------------------------------------------------------------
323 -- |-----------------------------< child_rows_exist >-------------------------|
324 -- ----------------------------------------------------------------------------
325 Procedure child_rows_exist
326 (p_ in number
327 ,p_start_date in date
328 ,p_end_date in date
329 );
330 --
331 end ame_apg_shd;