
 
 
 
 
 
CREATE OR REPLACE TRIGGER T_STEP_C1 
BEFORE/AFTER INSERT OR UPDATE ON BDO_Table 
FOR EACH ROW 
BEGIN 
   IF INSERTING THEN 
     INSERT INTO BDA_Table (BDA_Key_1, BDA_key_2, . . . ., BDA_Attribute_1, BDA_Attribute_2, . . . .) 
VALUES(:NEW.BDO_Key_1, NEW.BDO_Key_2, . . . .,  
:NEW.BDO_Attribute_1, :NEW.BDO_Attribute_2 . . . . .); 
   ELSE 
     IF :NEW.BDO_Attribute_1 <> :OLD.BDO_Attribute_1 OR  
NEW.BDO_Attribute_2 <> :OLD.BDO_Attribute_2 OR . . . . 
          INSERT INTO BDA_Table (BDA_Key_1, BDA_Key_2, . . . ., BDA_Attribute_1, BDA_Attribute_2, . . . .) 
          VALUES(:OLD.BDO_Key_1, :OLD.BDO_Key_2, . . . . , 
          :NEW/OLD.BDO_Attribute_1, :NEW/OLD.BDO_Attribute_2, . . . .); 
   END IF; 
E
D
 
Figure 4: Specification of Step C1. 
Step C2:
 Generation of Trigger for Step B2. 
This step complements Step C1 and has the 
objective to include dates in the tuples that have 
changes in attributes values.  The generic trigger 
proposed for this step is specified at Figure 5.  
 
 
 
 
CREATE OR REPLACE TRIGGER T_STEP_C2_1 
BEFORE/AFTER INSERT OR UPDATE OF BDO_Attribute_X ON BDO_Table 
FOR EACH ROW 
BEGIN 
  IF INSERTING THEN 
       INSERT INTO BDA_Table (BDA_Key_1, BDA_Key_2, . . . . ., 
       BDA_Attribute_1, BDA_Attribute_2, . . . ., BDA_Attribute_Time_1) 
       VALUES(:NEW.BDO_Key_1, NEW.BDO_Key_2, . . . ., 
       :NEW.BDO_Attribute_1, :NEW.BDO_Attribute_2 . . . . ., Date_Day); 
  ELSE 
    UPDATE BDA_Table SET BDA_Attribute_Time_2=Date_Day 
    WHERE BDA_Table.BDA_Attribute_X=:OLD. BDA_Attribute_X AND 
    BDA_Table.BDA_Key_1=:OLD.BDO_Key_1 AND BDA_Table.BDA_Key_2=:OLD.BDO_Key_2 AND . . .. 
    AND BDA_Table.BDA_Attribute_Time_2 is NULL; 
    INSERT INTO BDA_Table (BDA_Key_1, BDA_Key_2, . . . . ., 
     BDA_Attribute_1, BDA_Attribute_2, . . . ., BDA_Attribute_Time_1) 
     VALUES(:NEW.BDO_Key_1, NEW.BDO_Key_2, . . . ., 
     :NEW.BDO_Attribute_1, :NEW.BDO_Attribute_2 . . . . .,Date_Day); 
  END IF; 
 
Figure 5: Specification of Step C2. 
Step C3: Generation of Trigger for Step B3 
The objective of this step is the creation of a 
trigger to implement Step B3. The generic trigger 
proposed for this step is specified at Figure 6. 
 
 
 
 
CREATE OR REPLACE TRIGGER T_STEP_C3 
BEFORE/AFTER INSERT ON BDO_Table 
FOR EACH ROW 
BEGIN 
  INSERT INTO BDA_Table (BDA_Key_1, BDA_Key_2, . . . . , 
  BDA_Attribute_1, BDA_Attribute_2, . . . ., BDA_Attribute_Total_1, . . . . , 
  VALUES(:NEW.BDO_Key_1, NEW.BDO_Key_2, . . . ., :NEW.BDO_Attribute_1, :NEW.BDO_Attribute_2, . . 
. . ., :NEW.BDO_Attribute_Calc_1*:NEW.BDO_Attribute_Calc_2, . . . .,); 
END. 
 
Figure 6: Specification of Step C3. 
Step C4: Generation of Trigger for the Step B4 
The objective of this step is the creation of a 
trigger to implement Step B4. The generic trigger 
proposed for this step is specified at Figure 7. 
 
 
 
 
CREATE OR REPLACE TRIGGER T_STEP_C4 
BEFORE/AFTER INSERT OR UPDATE OF BDO_Attribute_1, BDO_Attribute_2, BDO_Attribute_3, . . . .  ON 
BDO_Table 
FOR EACH ROW 
BEGIN 
   IF INSERTING THEN 
        INSERT INTO BDA_Table(BDA_Key_1, BDA_Key_2, . . . . ,  
        BDA_Attribute_1,  BDA_Attribute_2, BDA_Attribute_3, . . . . , BDA_Attribute_Time_1)  
VALUES(:NEW.BDO_Key_1, :NEW.BDO_Key_2, . . . ., 
:NEW.BDO_Attribute_1, :NEW.BDO_Attribute_2, :NEW.BDO_Attribute_3, . . . . ,Date_Day); 
 ELSE 
        UPDATE BDA_Table SET BDA_Attribute_Time_2=Date_Day 
WHERE BDA_Table.BDA_Key_1=:OLD.BDO_Key_1 AND 
BDA_Table.BDA_Key_2=:OLD.BDO_Key_2, . . . . , AND BDA_Table.BDA_Attribute_Time_2 is NULL; 
        INSERT INTO BDA_Table(BDA_Key_1, BDA_Key_2, . . . . ,  
        BDA_Attribute_1,  BDA_Attribute_2, BDA_Attribute_3, . . . . , BDA_Attribute_Time_1)  
VALUES(:NEW.BDO_Key_1, :NEW.BDO_Key_2, . . . ., 
:NEW.BDO_Attribute_1, :NEW.BDO_Attribute_2, :NEW.BDO_Attribute_3, . . . . ,Date_Day); 
  END IF; 
 
Figure 7: Specification of Step C4. 
 
Step C5:
 Generation of Trigger for the Step B5 
The objective of this step is the creation of a 
procedure to implement Step B5. The generic 
procedure proposed for this step is specified at 
Figure 8. 
4  CONCLUSIONS  
This work described the creation of a historic 
database, which can be very useful for decision 
taking process. Besides, there will not be necessary 
the acquisition of expensive tools to make the 
generation of the analytical database, because the 
entire process can be implemented using triggers and 
procedures.  
It must be emphasized the implementation 
facility and the low cost of the solution proposed in 
this work, especially when compared to data 
warehouse technology, which is much more 
complex and expensive. 
For future work, we intend to study a real case, 
to show the applicability of this solution. 
 
 
 
 
 
CREATE OR REPLACE PROCEDURE P_STEP_C5 
 (Variable_Filter_1 IN BDA_Table.BDA_Attribute_1%TYPE, 
  Variable_Filter_2 IN BDA_Table.BDA_Attribute_2%TYPE, . . . . ) 
 IS 
  Variable_1 BDO_Table.BDO_Attribute_1%TYPE; Variable_2 BDO_Table.BDO_Attribute_2%TYPE;  . . . . .; 
  CURSOR BDO_Table_CURSOR IS 
SELECT BDO_Key_1, BDO_Key_2, . . . . , BDO_Attribute_1, BDO_Attribute_2, . . . . ,  
Sum(BDO_Attribute_Calc_1* BDO_Attribute_Calc_2), Sum(BDO_Attribute_Calc_3, . . . .) 
INTO Variable_1,Variable_2, . . . .  FROM BDO_Table 
WHERE BDO_Key_1=Variable_Filter_1 OR/AND . . . .  
OR BDO_Attribute_1=Variable_Filter_2 OR/AND . . . .  
GROUP BY BDO_Key_1, BDO_Key_2, . . . . , BDO_Attribute_1, BDO_Attribute_2, . . . ; 
 BEGIN 
    OPEN BDO_Table_CURSOR; 
    LOOP 
        FETCH BDO_Table_CURSOR INTO Variable_1, Variable_2, . . . . ; 
        EXIT WHEN BDO_Table_CURSOR%NOTFOUND; 
        DELETE FROM BDA_Table WHERE BDA_Key_1=Variable_Filter_1 OR/AND . . . .  
        OR BDA_Attribute_1=Variable_Filter_2 OR/AND . . . . ; 
        INSERT INTO BDA_Table (BDA_Key_1, BDA_Key_2, BDA_Attribute_1, 
        BDA_Attribute_2, BDA_Attribute_3, . . . . ) VALUES(Variable_1,Variable_2, . . . . ); 
     END LOOP; 
    COMMIT; 
END;
Figure 8: Specification of Step C5. 
ACKNOLEDGEMENTS 
The authors thank the support of FEMA (Fundação 
Educacional do Município de Assis) and FUSP 
(Fundação da Universidade de São Paulo), in the 
development of this work. 
REFERENCES 
Corey, Michael; Abbey, Michael; Abramson, Ian; Taub, 
Ben.  Oracle 8i Data Warehouse. Editora Campus, 
2001. 
Date, C J.; Introdução a Sistemas de Banco de Dados. 8ª 
edição – Rio de Janeiro: Elsevier, 2003. 
ICEIS 2007 - International Conference on Enterprise Information Systems
480