WHILE ASSIGNING A VALUE TO PROCESSED_TIME=:NEW.JMS_TIMESTAMP-:NEW.INS_TIME (All are timestamp type ) how to subtract that one.
CREATE OR REPLACE TRIGGER SAUUSER.TRG_MSGES_STATISTICS AFTER UPDATE OR UPDATE ON SAUUSER.TSAU_PRE_MSGES REFERENCING NEW AS NEW OLD AS OLD FOR EACH ROW DECLARE BEGIN IF INSERTING THEN INSERT INTO TSAU_MSGES_STATISTICS(PORTCODE,MSG_ID,DOCTYPE,MSGTYPE,SUBMISSION_TIME) VALUES(:NEW.PORTCODE, :NEW.MSG_ID, :NEW.DOCTYPE, :NEW.MSGTYPE, :NEW.INS_TIME ); END IF; IF UPDATING THEN UPDATE TSAU_MSGES_STATISTICS SET MSG_STATUS =:NEW.PROC_STATUS, RESPONSE_TIME =:NEW.JMS_TIMESTAMP, PROCESSED_TIME = :NEW.JMS_TIMESTAMP - :NEW.INS_TIME WHERE MSG_ID =:NEW.MSG_ID; END IF; EXCEPTION WHEN OTHERS THEN dbms_output.put_line( 'error in execute on TSAU_PRE_MSGES' ); END;
Software/Hardware used:
toad 9.5
ASKED:
July 6, 2010 11:50 AM
UPDATED:
July 7, 2010 1:33 PM
Rizwan, this is the same question you asked the other day. And you got the same answer.
Doing math on a TIMESTAMP does not yield a TIMESTAMP. It cannot. It does not. It should not. The difference between two dates is not a date, it is a number of days.
processed_time column belongs to tsau_msges_statistics table, jms_timestamp and ins_time belongs to tsau_pre_msges, i need to subtract (jms_timestamp and ins_time ) and assign to processed_time in update trigger.
jms_timestamp is a response_time ,
ins_time is a submission_time after subtracting this vl get response time that is wht i need. so plse help me urgently
We can see what columns belong to what tables in your code, and unfortunately you didn’t provide any additional details, nor did you provide example data.
As previously mentioned, the short answer is “you can’t”.
Arithmetic operations between timestamps columns don’t produce timestamp results.
Your response time column should be of some INTERVAL data type.