Results 1 to 2 of 2

Thread: trigger

  1. #1
    Join Date
    Nov 2002
    Posts
    22

    Unanswered: trigger

    hi guys
    I have tblemp (empID(pk), ename, sal, job, commision)
    how can i write a trigger on tblemp to;
    i have psudo not sure if its right! plus need help with syntax...plus not usre if its before or after?

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

    --I think;

    create or replace trigger trg_tblemp
    before insert or update on tblemp
    for each row
    begin
    if job = 'Salesperson' then
    :new.commission := '1';
    else
    :new.commission := '0';
    end if;

  2. #2
    Join Date
    Apr 2003
    Location
    Greenville, SC (USA)
    Posts
    1,155
    create or replace trigger trg_tblemp
    before insert or update on tblemp
    for each row
    begin
    if job = 'Salesperson' then
    :new.commission := '1';
    else
    :new.commission := '0';
    end if;

    end;
    /

    This should be a BEFORE trigger as you have it ...
    Add the last 2 lines and have fun
    Run it thru SQLPlus and compile it ...

    HTH
    Gregg

Posting Permissions

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