[Home] [Help]
PACKAGE BODY: APPS.CN_GET_EXPRESSION
Source
1 PACKAGE BODY cn_get_expression AS
2 -- $Header: cngtexpb.pls 120.1 2005/07/18 03:28:31 rramakri noship $
3 --==========================================================================
4 -- Procedure Name: BUILD_TABLE
5 -- Purpose
6 --==========================================================================
7 PROCEDURE build_table (x_rule_id IN cn_rule_attr_expression.rule_id%TYPE,
8 x_usage IN VARCHAR2,
9 x_org_id IN cn_rule_attr_expression.org_id%TYPE) IS
10
11
12 CURSOR get_rae (x_rule_id NUMBER,x_org_id NUMBER) IS
13 SELECT operand1, operand1_ra_rae_flag,
14 operand2, operand2_ra_rae_flag,
15 operator
16 FROM cn_rule_attr_expression
17 WHERE rule_id = x_rule_id and org_id=x_org_id
18 ORDER BY operand_expression_id;
19
20 CURSOR get_ra_descriptive (x_ra_id NUMBER,x_org_id NUMBER) IS
21 SELECT descriptive_rule_attribute
22 FROM cn_rule_attributes_desc_v
23 WHERE attribute_rule_id = x_ra_id
24 and org_id=x_org_id;
25
26 get_ra_descriptive_rec get_ra_descriptive%ROWTYPE;
27
28 l_lexpr VARCHAR2(16000);
29 l_rexpr VARCHAR2(16000);
30 l_operator cn_lookups.meaning%TYPE;
31 BEGIN
32
33 g_intermediate_expr := 0;
34 FOR i IN get_rae(x_rule_id,x_org_id)
35 LOOP
36 IF i.operand1_ra_rae_flag = 'RA'
37 THEN
38 OPEN get_ra_descriptive(i.operand1,x_org_id);
39 FETCH get_ra_descriptive INTO get_ra_descriptive_rec;
40 l_lexpr := '('||get_ra_descriptive_rec.descriptive_rule_attribute||')';
41 CLOSE get_ra_descriptive;
42 ELSIF i.operand1_ra_rae_flag = 'RAE'
43 THEN
44 l_lexpr := g_rae(i.operand1);
45 END IF;
46
47 IF i.operand2_ra_rae_flag = 'RA'
48 THEN
49 OPEN get_ra_descriptive(i.operand2,x_org_id);
50 FETCH get_ra_descriptive INTO get_ra_descriptive_rec;
51 l_rexpr := '('||get_ra_descriptive_rec.descriptive_rule_attribute||')';
52 CLOSE get_ra_descriptive;
53 ELSIF i.operand2_ra_rae_flag = 'RAE'
54 THEN
55 l_rexpr := g_rae(i.operand2);
56 END IF;
57
58 IF x_usage = 'Code Generation'
59 THEN
60 IF i.operator = 1
61 THEN
62 l_operator := 'OR';
63 ELSIF i.operator = 0
64 THEN
65 l_operator := 'AND';
66 END IF;
67 ELSIF x_usage = 'Expression Display'
68 THEN
69 IF i.operator = 1
70 THEN
71 l_operator := cn_api.get_lkup_meaning('OR', 'Expression Messages');
72 ELSIF i.operator = 0
73 THEN
74 l_operator := cn_api.get_lkup_meaning('AND', 'Expression Messages');
75 END IF;
76 END IF;
77
78 g_intermediate_expr := g_intermediate_expr + 1;
79 --g_rae(g_intermediate_expr) := '('||l_lexpr||' '||l_operator||' '||l_rexpr||')';
80 g_rae(g_intermediate_expr) := substr('('||l_lexpr||' '||l_operator||' '||l_rexpr||')', 1, 1900);
81 ----------problem is out here bcos of the length of the expression.
82 END LOOP;
83
84 END;
85
86 --=======================================================================
87 -- Procedure Name: MAIN
88 -- Purpose
89 --=======================================================================
90 PROCEDURE main(x_rule_id IN cn_rule_attr_expression.rule_id%TYPE,
91 x_org_id IN cn_rule_attr_expression.org_id%TYPE,
92 x_usage IN VARCHAR2,
93 x_expression OUT NOCOPY VARCHAR2) IS
94 BEGIN
95 --Call build_table procedure to build a PL/SQL table of intermediate
96 --results or rule attribute expressions.
97 build_table ( x_rule_id, x_usage,x_org_id );
98
99 -- Added by Kumar.S
100 if g_rae.count > 0 then
101 x_expression := substr(g_rae(g_intermediate_expr),1,1900);
102 end if;
103
104
105 UPDATE cn_attribute_rules
106 SET expression = substr(x_expression, 1, 1900)
107 WHERE rule_id = x_rule_id and org_id=x_org_id;
108 commit;
109
110 EXCEPTION
111 when no_data_found then
112 null;
113 END main;
114
115 PROCEDURE deleteExpression(x_rule_id IN cn_attribute_rules.rule_id%TYPE,
116 x_org_id IN cn_attribute_rules.org_id%TYPE) IS
117 BEGIN
118 UPDATE cn_attribute_rules set expression = ' ' WHERE rule_id = x_rule_id and org_id=x_org_id;
119 commit;
120 END deleteExpression;
121
122 END cn_get_expression;