DBAsupport.com Forums - Powered by vBulletin
Results 1 to 2 of 2

Thread: simple trigger

  1. #1
    Join Date
    Jul 2000
    Location
    brewster,Newyork
    Posts
    87
    Guys
    I have a table log with these cols
    pvid,barnd,login_time,logout_time,total_time.
    This table gets populated by a trigger
    CREATE OR REPLACE TRIGGER PV.UPDATE_GLOBAL_LOG
    AFTER UPDATE OF LOGOUT_TIME
    ON PV.GLOBAL_USERS
    REFERENCING OLD AS OLD NEW AS NEW
    FOR EACH ROW
    begin
    insert into global_users_log values(:new.pvid,:new.branding_id,:new.login_time,:new.logout_time);
    end;

    This trigger doesnt populates Total_time column in table.This being newcolumn we want this to be populated thro same trigger only and the value should be logout_time-login_time.
    Can we do this and request u guys let me know how to do?
    Thanks folks


    sat

  2. #2
    Join Date
    Sep 2000
    Posts
    47
    Hi,

    The insert statement in your after update trigger PV.UPDATE_GLOBAL_LOG does not contains the column TOTAL_TIME. I wonder how the insert st. is working ..... anyway just update the trigger to include the following insert statement :

    insert into global_users_log (pvid, barnd, login_time, logout_time, total_time) values(:new.pvid, :new.branding_id, :new.login_time, :new.logout_time, NVL(:NEW.logout_time,0) - NVL(:NEW.login_time,0) );

    This should work.

    In triggers always use NVL functions when dealing with numerical values. Numeric columns may have NULL values.

    Good Luck.

    Pinakin.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width