How to validate a Trigger with a Function? - Oracle

2

I am still incurring the Oracle world and I encountered a Situation. I would appreciate even the slightest suggestion or help:).

Now, I have a "SENSOR" Table with a "QUERYS" field, this field has records with queries that will simply return numerical values. To make this possible I built a Function: The only thing that my Function does is to load these Queries in my Sensor Table and of course to give me back their respective values.

An example would be the following:

SELECT FN_INDICADOR(IDSENSOR) FROM SENSOR;

This will return the already loaded values.

I have a Trigger that the only thing I basically do is register the Current Date in my "Update" field after Modifying a record of any field in my SENSOR table.

 CREATE OR REPLACE TRIGGER t1
 BEFORE UPDATE ON SENSOR REFERENCING NEW AS NEW OLD AS OLD 
 FOR EACH ROW
 DECLARE 
  v_fecha DATE;
 BEGIN
   v_fecha :=SYSDATE;
   SELECT SYSDATE INTO v_fecha FROM DUAL;
   :NEW.ACTUALIZACION :=v_fecha;
 END;

What I was thinking about doing is invoking my Function from this Trigger so that it fulfills the following Validation:

Each time the values returned by my function change or are modified, the date on which this value was altered is recorded in my "UPDATE" field. If some are able to ask how these values are going to change or change, it is because this table is in production, so its values will be in constant change.

If there is another solution it would be great: D, I hope you let me understand.

    
asked by Fullguitar 21.02.2018 в 16:38
source

0 answers