1 package ff_exec AUTHID CURRENT_USER as
2 /* $Header: ffexec.pkh 115.9 2003/01/20 18:10:06 arashid ship $ */
3 g_debug boolean;
4 /*
5 Notes:
6 This version of the execution engine relies on PL/SQL release 2.3
7 or later (i.e. it uses PL/SQL tables of records). Therefore there
8 is a separate set of library routines to allow calling formula
9 from forms.
10
11 For detailed design notes and examples on how to call the
12 execution engine, please see the associated low level design.
13 The filename for this is ffrunf.lld and is held under $FF_TOP/lld
14 directory.
15
16 Also, please refer to this documentation for explanation of the
17 logging strategy for this module, as there are some improvements
18 to the normal standard.
19 */
20 /*
21 * Debug level constants.
22 * These values can be used in conjunction with the set_debug
23 * procedure to control debug output from the execution engine.
24 */
25 FF_DBG constant binary_integer := 2;
26 FF_CACHE_DBG constant binary_integer := 4;
27 DBI_CACHE_DBG constant binary_integer := 8;
28 MRU_DBG constant binary_integer := 16;
29 IO_TABLE_DBG constant binary_integer := 32;
30 FF_BIND_LEN constant binary_integer := 255; -- input/return values.
31
32 /*
33 * Definition of record to hold inputs to formula.
34 * NOTES:
35 * o This record is used for both contexts and input values.
36 * o This record is instantiated by a call to the init_formula
37 * procedure.
38 * o Dates should be passed in the apps Canonical format.
39 * o The 'datatype' member is used to indicate the datatype of
40 * the input. It's value should not be set by the caller.
41 * o The 'class' member is used to indicate whether the input
42 * is a context or a formula input. It's value should not
43 * be set by the caller.
44 */
45 type inputs_r is record
46 (
47 name varchar2(240),
48 datatype varchar2(6), -- 'DATE', 'NUMBER', 'TEXT'
49 class varchar2(7), -- 'CONTEXT' or 'INPUT'.
50 value varchar2(255) -- NOTE: match FF_BIND_LEN
51 );
52
53 /*
54 * Definition of table to hold inputs to formula.
55 * NOTES:
56 * o The index for this table is guaranteed to start at 1
57 * and be contiguous throughout.
58 * o This table is instantiated by a call to the init_formula
59 * procedure.
60 */
61 type inputs_t is table of inputs_r index by binary_integer;
62
63 /*
64 * Definition of record to hold outputs from formula.
65 * NOTES:
66 * o This record is instantiated by a call to the init_formula
67 * procedure.
68 * o Dates will be returned in the apps Canonical format.
69 * o The 'datatype' member is used to indicate the datatype of
70 * the output. It's value should not be set by the caller.
71 */
72 type outputs_r is record
73 (
74 name varchar2(240),
75 datatype varchar2(6), -- 'DATE', 'NUMBER', 'TEXT'
76 value varchar2(255) -- NOTE: match FF_BIND_LEN
77 );
78
79 /*
80 * Definition of table to hold outputs to formula.
81 * NOTES:
82 * o The index for this table is guaranteed to start at 1
83 * and be contiguous throughout.
84 * o This table is instantiated by a call to the init_formula
85 * procedure.
86 */
87 type outputs_t is table of outputs_r index by binary_integer;
88
89 /*
90 * The following global variables hold the number of contexts,
91 * inputs and outputs required by the currently executing formula.
92 * Therefore, they need to be examined after calling init_formula.
93 */
94 context_count binary_integer;
95 input_count binary_integer;
96 output_count binary_integer;
97
98 ------------------------------- reset_caches ----------------------------------
99 /*
100 NAME
101 reset_caches
102 DESCRIPTION
103 Resets the internal caches to their initial states.
104 */
105 procedure reset_caches;
106
107
108 ---------------------------- init_formula -------------------------------------
109 /*
110 NAME
111 init_formula
112 DESCRIPTION
113 Initialises data structures for a specific formula.
114 NOTES
115 The first call to this function initialises the execution engine.
116 The input and output tables are initialised by this call so
117 that the user knows the names of all the inputs, contexts and
118 outputs that they should set/expect to be returned.
119 */
120
121 procedure init_formula
122 (
123 p_formula_id in number,
124 p_effective_date in date,
125 p_inputs in out nocopy ff_exec.inputs_t,
126 p_outputs in out nocopy ff_exec.outputs_t
127 );
128
129 ------------------------------ run_formula ------------------------------------
130 /*
131 NAME
132 init_formula
133 DESCRIPTION
134 Uses data structures built up to execute Fast Formula.
135 NOTES
136 The p_use_dbi_cache parameter controls whether the db
137 item cache will be used when executing formulas. The only
138 circumstance where this should be set to 'false' is when
139 being called from the API user hooks functionality.
140 */
141
142 procedure run_formula
143 (
144 p_inputs in ff_exec.inputs_t,
145 p_outputs in out nocopy ff_exec.outputs_t,
146 p_use_dbi_cache in boolean default true
147 );
148
149 end ff_exec;