Oracle-developers

30 pts.
Tags:
Oracle applications
Oracle development
Timestamp
TOAD
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

Answer Wiki

Thanks. We'll let you know when a new response is added.

When you subtract two TIMESTAMP columns you get a time difference, not a date, and the resulting data type is INTERVAL DAY(x) TO SECOND(y).

You could add this result to another TIMESTAMP to get a TIMESTAMP result, but I’m not sure why you would want to do that.

You might want to provide some example data showing the two timestamps you would subtract and the resulting timestamp you would want to get, to clarify your requirement.

Discuss This Question: 3  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Meandyou
    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.
    5,220 pointsBadges:
    report
  • RizwanSharief
    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
    30 pointsBadges:
    report
  • carlosdl
    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.
    70,220 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following