Re: trigger - help newbie!
Date: 22 Aug 2001 05:31:54 -0700
Message-ID: <31d3e92a.0108220431.16e5b1da_at_posting.google.com>
"Steve Long" <slong3_at_mediaone.net> wrote in message news:<iA%e7.1609$L8.23391_at_typhoon.jacksonville.mediaone.net>...
> this depends on how/when you are examining the value. since you have an
> "after insert" trigger, you will not see the new value until a COMMIT is
> issued. sounds like autocommit is not on. thus, after running the PL/SQL
> block, issue a COMMIT, and then check the value.
>
> "sien" <linda_68_at_hotmail.com> wrote in message
> news:31d3e92a.0108160029.27f5e54b_at_posting.google.com...
> > Hi!
> > I'm a newbie in PL/SQL.
> > I'm trying to write a trigger which has to update a specific row from
> > a table after someone insert a new row into the same table.
> > This is my code:
> >
> > CREATE OR REPLACE TRIGGER CHG_DATE_TEST
> >
> > after INSERT ON emp
> >
> > BEGIN
> > update emp
> > set emp.hiredate=sysdate
> > where (empno=7566);
> >
> > end CHG_DATE_TEST;
> >
> > it doesn't work, the trigger doesn't change the row I want to update
> > (where empno=7566), but it updates the hiredate from the new
> > (inserted)row.
> >
> > Thanks for any help.
> >
> > Sien
Yap, it works, thanks!
Anyway, do you know how can I update the row which caused the tiger
fired?
CREATE OR REPLACE TRIGGER CHG_DATE_TEST
after INSERT or update ON emp
BEGIN
update emp
set emp.hiredate=sysdate
where (empno=???);
end CHG_DATE_TEST;
what should I write in the condition of empno? I tried where empno=:new.empno, but it changed the hiredate of all the rows in the table!
Thanks a lot!
Sien Received on Wed Aug 22 2001 - 14:31:54 CEST