Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Help writing simple trigger.
>For some reason I can't figure out how to write a simple
>trigger but I know it's very common so I'll ask for some help.
>It's a busy day!
>
>This trigger updates user_name and lastedit_date on a table during and
update
>or insert operation for each row and maybe fill in the pk with a sequence
>number.... CREATE TRIGGER UPD_TRG BEFORE INSERT OR UPDATE ON dbstruct
>BEGIN user_name=user lastedit_date=sysdate recno=dbstructseq.nextval
END;
>
>When I write my function I get table is mutating error.
>It should operate in the same transaction as the insert update.
>
>I.E. 1 update staement+trigger = 1 transction...=1 SQL parse..
>
>
>Thank You very much!!!!
>
>-----------== Posted via Deja News, The Discussion Network ==----------
>http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
the following should work:
create trigger upd_trg before insert or update ob dbstruct for each row
begin
:new.user_name := user;
:new.lastedit_date:=sysdate;
if inserting then
select debstructseq.nextval into :new.recno from dual;
end if;
end;
yours
uli
Received on Fri Feb 26 1999 - 10:55:05 CST