URGENT help on a trigger [message #38973] |
Sun, 02 June 2002 17:07 |
Australia
Messages: 4 Registered: May 2002
|
Junior Member |
|
|
Hi, can someone please help e with this trigger. I have done it, but i dont think its right. here is the pseudo code, followed by what code i have written for the trigger. Help will be GREATLY appreciated!
PSEUDO CODE:
trigger name: aft_in_del_people_row_tgr
event: insert or delete on people
timing nad type: before row
action:
if the user issuing the update does not have username 'ADMIN'then
raise error (-20030 'User not permitted to perform action')
end if
if there is no change_log row or the relevant people id then
create such a change_log row with all counts zero and today's date
end if
increment the appropriate count, icount or dcount, of the relevant change_log row
MY CODE:
create or replace trigger aft_in_del_people_row_tgr
before insert or delete on people
for each row
begin
if(:new.username<> lower(user)) and user <> 'ADMIN' then
raise_application_error (-20030, 'User not permitted to perform action');
end if;
if sql%rowcount = 0 then
insert into change_log values(:new.people_id, 1, sysdate);
end if;
update change_log
set ucount = ucount + 1
where people_id = :new.people_id;
end;
/
|
|
|
|