DBA Data[Home] [Help]

PACKAGE BODY: APPS.FF_FFXWSDFF_PKG

Source


1 package body ff_ffxwsdff_pkg as
2 /* $Header: ffxwsdff.pkb 115.1 99/07/16 02:04:17 porting ship $ */
3 
4 --------------------------------------------------------
5 -- I : Row handlers for FF_FUNCTIONS                  --
6 --------------------------------------------------------
7 
8 procedure insert_function(x_rowid       in out varchar2,
9                           x_function_id in out number,
10                           x_class              varchar2,
11                           x_name               varchar2,
12                           x_alias_name         varchar2,
13                           x_business_group_id  number,
14                           x_created_by         number,
15                           x_creation_date      date,
16                           x_data_type          varchar2,
17                           x_definition         varchar2,
18                           x_last_updated_by    number,
19                           x_last_update_date   date,
20                           x_last_update_login  number,
21                           x_legislation_code   varchar2,
22                           x_description        varchar2
23                          ) is
24 
25   cursor c_rowid is
26     select rowid
27     from ff_functions
28     where function_id = x_function_id;
29 
30   cursor c_sequence is
31     select ff_functions_s.nextval
32     from dual;
33 
34 begin
35 
36   open c_sequence;
37   fetch c_sequence into x_function_id;
38   if (c_sequence%notfound) then
39     close c_sequence;
40     raise no_data_found;
41   end if;
42   close c_sequence;
43 
44   insert into ff_functions(
45     function_id,
46     class,
47     name,
48     alias_name,
49     business_group_id,
50     created_by,
51     creation_date,
52     data_type,
53     definition,
54     last_updated_by,
55     last_update_date,
56     last_update_login,
57     legislation_code,
58     description
59   )values(
60     x_function_id,
61     x_class,
62     x_name,
63     x_alias_name,
64     x_business_group_id,
65     x_created_by,
66     x_creation_date,
67     x_data_type,
68     x_definition,
69     x_last_updated_by,
70     x_last_update_date,
71     x_last_update_login,
72     x_legislation_code,
73     x_description
74   );
75 
76   open c_rowid;
77   fetch c_rowid into x_rowid;
78   if (c_rowid%notfound) then
79    close c_rowid;
80     raise no_data_found;
81   end if;
82   close c_rowid;
83 
84 end insert_function;
85 
86 
87 procedure lock_function(x_rowid              varchar2,
88                         x_function_id        number,
89                         x_class              varchar2,
90                         x_name               varchar2,
91                         x_alias_name         varchar2,
92                         x_business_group_id  number,
93                         x_created_by         number,
94                         x_creation_date      date,
95                         x_data_type          varchar2,
96                         x_definition         varchar2,
97                         x_last_updated_by    number,
98                         x_last_update_date   date,
99                         x_last_update_login  number,
100                         x_legislation_code   varchar2,
101                         x_description        varchar2
102                        ) is
103 
104   cursor c_row is
105     select function_id,
106     class,
107     name,
108     alias_name,
109     business_group_id,
110     data_type,
111     definition,
112     legislation_code,
113     description
114   from ff_functions
115   where rowid = x_rowid
116   for update of function_id nowait;
117 
118   recinfo c_row%rowtype;
119 
120 begin
121 
122   open c_row;
123   fetch c_row into recinfo;
124   if (c_row%notfound) then
125     close c_row;
126     fnd_message.set_name('FND', 'FORM_RECORD_DELETED');
127     app_exception.raise_exception;
128   end if;
129   close c_row;
130   if (
131           (recinfo.function_id = x_function_id)
132       and (recinfo.class = x_class)
133       and (recinfo.name = x_name)
134       and (   (recinfo.alias_name = x_alias_name)
135            or (    (recinfo.alias_name is null)
136                and (x_alias_name is null)))
137       and (   (recinfo.business_group_id = x_business_group_id)
138            or (    (recinfo.business_group_id is null)
139                and (x_business_group_id is null)))
140       and (   (recinfo.data_type = x_data_type)
141            or (    (recinfo.data_type is null)
142                and (x_data_type is null)))
143       and (   (recinfo.definition = x_definition)
144            or (    (recinfo.definition is null)
145                and (x_definition is null)))
146       and (   (recinfo.legislation_code = x_legislation_code)
147            or (    (recinfo.legislation_code is null)
148                and (x_legislation_code is null)))
149       and (   (recinfo.description = x_description)
150            or (    (recinfo.description is null)
151                and (x_description is null)))
152      ) then
153     return;
154   else
155     fnd_message.set_name('FND', 'FORM_RECORD_CHANGED');
156     app_exception.raise_exception;
157   end if;
158 
159 end lock_function;
160 
161 
162 procedure update_function(x_rowid              varchar2,
163                           x_function_id        number,
164                           x_class              varchar2,
165                           x_name               varchar2,
166                           x_alias_name         varchar2,
167                           x_business_group_id  number,
168                           x_created_by         number,
169                           x_creation_date      date,
170                           x_data_type          varchar2,
171                           x_definition         varchar2,
172                           x_last_updated_by    number,
173                           x_last_update_date   date,
174                           x_last_update_login  number,
175                           x_legislation_code   varchar2,
176                           x_description        varchar2
177                          ) is
178 
179 begin
180 
181   update ff_functions set
182     function_id       = x_function_id,
183     class             = x_class,
184     name              = x_name,
185     alias_name        = x_alias_name,
186     business_group_id = x_business_group_id,
187     created_by        = x_created_by,
188     creation_date     = x_creation_date,
189     data_type         = x_data_type,
190     definition        = x_definition,
191     last_updated_by   = x_last_updated_by,
192     last_update_date  = x_last_update_date,
193     last_update_login = x_last_update_login,
194     legislation_code  = x_legislation_code,
195     description       = x_description
196   where rowid = x_rowid;
197 
198   if (sql%notfound) then
199     raise no_data_found;
200   end if;
201 
202 end update_function;
203 
204 
205 procedure delete_function(x_rowid       varchar2,
206                           x_function_id number) is
207 
208 begin
209 
210   delete from ff_functions
211   where rowid = x_rowid;
212 
213   delete from ff_function_context_usages
214   where function_id = x_function_id;
215 
216   delete from ff_function_parameters
217   where function_id = x_function_id;
218 
219 end delete_function;
220 
221 
222 -------------------------------------------------------------
223 -- II : Row handlers for FF_FUNCTION_CONTEXT_USAGES        --
224 -------------------------------------------------------------
225 
226 procedure insert_context_usage(x_rowid       in out varchar2,
227                                x_function_id        number,
228                                x_sequence_number    number,
229                                x_context_id         number
230                               ) is
231 
232   cursor c_rowid is
233     select rowid
234     from ff_function_context_usages
235     where function_id = x_function_id;
236 
237 begin
238 
239   insert into ff_function_context_usages(
240     function_id,
241     sequence_number,
242     context_id
243   )values(
244     x_function_id,
245     x_sequence_number,
246     x_context_id
247   );
248 
249   open c_rowid;
250   fetch c_rowid into x_rowid;
251   if (c_rowid%notfound) then
252    close c_rowid;
253     raise no_data_found;
254   end if;
255   close c_rowid;
256 
257 end insert_context_usage;
258 
259 
260 procedure lock_context_usage(x_rowid              varchar2,
261                              x_function_id        number,
262                              x_sequence_number    number,
263                              x_context_id         number
264                             ) is
265 
266   cursor c_row is
267     select function_id,
268     sequence_number,
269     context_id
270   from ff_function_context_usages
271   where rowid = x_rowid
272   for update of function_id nowait;
273 
274   recinfo c_row%rowtype;
275 
276 begin
277 
278   open c_row;
279   fetch c_row into recinfo;
280   if (c_row%notfound) then
281     close c_row;
282     fnd_message.set_name('FND', 'FORM_RECORD_DELETED');
283     app_exception.raise_exception;
284   end if;
285   close c_row;
286   if (
287           (recinfo.function_id = x_function_id)
288       and (recinfo.sequence_number = x_sequence_number)
289       and (recinfo.context_id = x_context_id)
290      ) then
291     return;
292   else
293     fnd_message.set_name('FND', 'FORM_RECORD_CHANGED');
294     app_exception.raise_exception;
295   end if;
296 
297 end lock_context_usage;
298 
299 
300 procedure update_context_usage(x_rowid              varchar2,
301                                x_function_id        number,
302                                x_sequence_number    number,
303                                x_context_id         number
304                               ) is
305 
306 begin
307 
308   update ff_function_context_usages set
309     function_id       = x_function_id,
310     sequence_number   = x_sequence_number,
311     context_id        = x_context_id
312   where rowid = x_rowid;
313 
314   if (sql%notfound) then
315     raise no_data_found;
316   end if;
317 
318 end update_context_usage;
319 
320 
321 procedure delete_context_usage(x_rowid varchar2) is
322 
323 begin
324 
325   delete from ff_function_context_usages
326   where rowid = x_rowid;
327 
328   if (sql%notfound) then
329     raise no_data_found;
330   end if;
331 
332 end delete_context_usage;
333 
334 
335 -----------------------------------------------------------
336 -- III : Row handlers for FF_FUNCTION_PARAMETERS         --
337 -----------------------------------------------------------
338 
339 procedure insert_parameter(x_rowid         in out varchar2,
340                            x_function_id          number,
341                            x_sequence_number      number,
342                            x_class                varchar2,
343                            x_continuing_parameter varchar2,
344                            x_data_type            varchar2,
345                            x_name                 varchar2,
346                            x_optional             varchar2
347                           ) is
348 
349   cursor c_rowid is
350     select rowid
351     from ff_function_parameters
352     where function_id = x_function_id;
353 
354 begin
355 
356   insert into ff_function_parameters(
357     function_id,
358     sequence_number,
359     class,
360     continuing_parameter,
361     data_type,
362     name,
363     optional
364   )values(
365     x_function_id,
366     x_sequence_number,
367     x_class,
368     x_continuing_parameter,
369     x_data_type,
370     x_name,
371     x_optional
372   );
373 
374   open c_rowid;
375   fetch c_rowid into x_rowid;
376   if (c_rowid%notfound) then
377     close c_rowid;
378     raise no_data_found;
379   end if;
380   close c_rowid;
381 
382 end insert_parameter;
383 
384 
385 procedure lock_parameter(x_rowid                varchar2,
386                          x_function_id          number,
387                          x_sequence_number      number,
388                          x_class                varchar2,
389                          x_continuing_parameter varchar2,
390                          x_data_type            varchar2,
391                          x_name                 varchar2,
392                          x_optional             varchar2
393                         ) is
394 
395   cursor c_row is
396     select function_id,
397     sequence_number,
398     class,
399     continuing_parameter,
400     data_type,
401     name,
402     optional
403   from ff_function_parameters
404   where rowid = x_rowid
405   for update of function_id nowait;
406 
407   recinfo c_row%rowtype;
408 
409 begin
410 
411   open c_row;
412   fetch c_row into recinfo;
413   if (c_row%notfound) then
414     close c_row;
415     fnd_message.set_name('FND', 'FORM_RECORD_DELETED');
416     app_exception.raise_exception;
417   end if;
418   close c_row;
419   if (
420           (recinfo.function_id = x_function_id)
421       and (recinfo.sequence_number = x_sequence_number)
422       and (recinfo.class = x_class)
423       and (recinfo.continuing_parameter = x_continuing_parameter)
424       and (recinfo.data_type = x_data_type)
425       and (recinfo.name = x_name)
426       and (recinfo.optional = x_optional)
427      ) then
428     return;
429   else
430     fnd_message.set_name('FND', 'FORM_RECORD_CHANGED');
431     app_exception.raise_exception;
432   end if;
433 
434 end lock_parameter;
435 
436 
437 procedure update_parameter(x_rowid                varchar2,
438                            x_function_id          number,
439                            x_sequence_number      number,
440                            x_class                varchar2,
441                            x_continuing_parameter varchar2,
442                            x_data_type            varchar2,
443                            x_name                 varchar2,
444                            x_optional             varchar2
445                           ) is
446 
447 begin
448 
449   update ff_function_parameters set
450     function_id          = x_function_id,
451     sequence_number      = x_sequence_number,
452     class                = x_class,
453     continuing_parameter = x_continuing_parameter,
454     data_type            = x_data_type,
455     name                 = x_name,
456     optional             = x_optional
457   where rowid = x_rowid;
458 
459   if (sql%notfound) then
460     raise no_data_found;
461   end if;
462 
463 end update_parameter;
464 
465 
466 procedure delete_parameter(x_rowid varchar2) is
467 
468 begin
469 
470   delete from ff_function_parameters
471   where rowid = x_rowid;
472 
473   if (sql%notfound) then
474     raise no_data_found;
475   end if;
476 
477 end delete_parameter;
478 
479 
480 ---------------------------------------------------------------------
481 -- IV : Other functions and procedures needed for FFXWSDFF         --
482 ---------------------------------------------------------------------
483 
484 ---------------------------------------------------------------------
485 -- next_parameter_sequence
486 --
487 -- Returns the next available parameter sequence number
488 -- to maintain a sequence of parameters within a particular function.
492 
489 ---------------------------------------------------------------------
490 
491 function next_parameter_sequence(p_function_id number) return number is
493   v_parameter_sequence number := null;
494 
495   cursor c_next_parameter_sequence is
496     select  nvl (max (sequence_number), 0) + 1
497     from    ff_function_parameters
498     where   function_id = p_function_id;
499 
500 begin
501 
502   open c_next_parameter_sequence;
503   fetch c_next_parameter_sequence into v_parameter_sequence;
504   close c_next_parameter_sequence;
505 
506   return v_parameter_sequence;
507 
508 end next_parameter_sequence;
509 
510 
511 ---------------------------------------------------------------------
512 -- next_context_usage_sequence
513 --
514 -- Returns the next available context usage sequence number
515 -- to maintain a sequence of contexts within a particular function.
516 ---------------------------------------------------------------------
517 
518 function next_context_usage_sequence(p_function_id number) return number is
519 
520   v_context_sequence number := null;
521 
522   cursor c_next_context_sequence is
523     select  nvl (max (sequence_number), 0) + 1
524     from    ff_function_context_usages
525     where   function_id = p_function_id;
526 
527 begin
528 
529   open c_next_context_sequence;
530   fetch c_next_context_sequence into v_context_sequence;
531   close c_next_context_sequence;
532 
533   return v_context_sequence;
534 
535 end next_context_usage_sequence;
536 
537 
538 ---------------------------------------------------------------------
539 -- check_alias_name
540 --
541 -- Ensures that the alias name is different to the function name
542 -- within the FUNCTION block.
543 ---------------------------------------------------------------------
544 
545 procedure check_alias_name(p_function_name varchar2,
546                            p_alias_name    varchar2) is
547 
548 begin
549 
550   if p_alias_name = p_function_name then
551     fnd_message.set_name('FF','FF_52245_BAD_ALIAS_NAME');
552     app_exception.raise_exception;
553   end if;
554 
555 end check_alias_name;
556 
557 
558 ---------------------------------------------------------------------
559 -- set_parameter_properties
560 --
561 -- Sets the correct OPTIOANL and CONTINUING_PARAMETER properties for
562 -- a parameter class of 'out' or 'in out'.
563 ---------------------------------------------------------------------
564 
565 procedure set_parameter_properties(p_class                       varchar2,
566                                    p_optional             in out varchar2,
567                                    p_continuing_parameter in out varchar2) is
568 
569 begin
570 
571   if (p_class <> 'I') then
572     p_optional := 'N';
573     p_continuing_parameter := 'N';
574   end if;
575 
576 end set_parameter_properties;
577 
578 
579 end ff_ffxwsdff_pkg;
580