Home » SQL & PL/SQL » SQL & PL/SQL » URGENT help on a trigger
URGENT help on a trigger [message #38973] Sun, 02 June 2002 17:07 Go to next message
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;
/
Re: URGENT help on a trigger [message #38978 is a reply to message #38973] Mon, 03 June 2002 09:10 Go to previous message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
Well, you've switched around the code sample I gave you earlier.

You need to try the update, check sql%rowcount, and if it is 0, do the insert.
Previous Topic: static data and dynamic data
Next Topic: Using Variables in Cursors
Goto Forum:
  


Current Time: Tue May 21 22:45:25 CDT 2024