Thread: re: trigger

    #1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2003
    Posts
    5
    Rep Power
    0

    Angry re: trigger


    hi guys how can i write a trigger on myemp tabl to;

    1. Sales persons should always receive commission. Employees who are not sales persons should never receive a commission;

    2. Salaries may only be increased, never decreased.
  2. #2
  3. No Profile Picture
    Senior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Location
    Canada
    Posts
    308
    Rep Power
    11
    I just type a trigger for:
    (2)Salaries may only be increased, never decreased.

    CRAETE TRIGGER salary_check
    BEFORE
    INSERT OR UPDATE OF salary ON myemp
    FOR EACH ROW
    DECLARE
    currsal number;
    BEGIN
    SELECT salary INTO currsal
    FROM myemp
    WHERE employee# = :new.employee#;

    IF (:new.sal < currsal) THEN
    raise_application_error (-20888, 'New salary for this empoyee ' || :new.employee# || ' must be greater than its current salary');
    END IF;
    END;
    /

    Regards

IMN logo majestic logo threadwatch logo seochat tools logo