Re: Help Me (Oracel Trigger Problem)
From: Frank van Bortel <f.van.bortel_at_vnl.nl>
Date: Tue, 29 Dec 1998 09:13:18 +0100
Message-ID: <36888F1D.822582DE_at_vnl.nl>
--
Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit
<br><tt> , mod_date</tt>
<br><tt> , old_sal</tt>
<br><tt> , new_sal )</tt>
<br><tt> , :new.sal )</tt>
<br><tt> ;</tt><tt></tt>
<p><tt> RAISE_APPLICATION_ERROR(-20500,</tt> <br><tt> 'You may olny update Salary of PRESIDENT. !!');</tt>
<br>Watch out with the error message: there's no stopping a clever hacker <br>from changing his/her job to president, up his/her salary, and change it back again!
<br>>president or just the people not the president. Also see if the trigger
<br>>> :old.sal, :new.sal);
Date: Tue, 29 Dec 1998 09:13:18 +0100
Message-ID: <36888F1D.822582DE_at_vnl.nl>
[Quoted] [Quoted] Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit
Is this what you're looking for?
CREATE OR REPLACE TRIGGER get_hacker
BEFORE UPDATE OF sal ON emp
FOR EACH ROW
BEGIN
IF (old.job <> 'PRESIDENT')
THEN
INSERT INTO guard ( hacker , mod_date , old_sal , new_sal ) VALUES ( user , to_char(sysdate,'yy/mm/dd hh24:mi:ss') , :old.sal , :new.sal ) ; RAISE_APPLICATION_ERROR(-20500, 'You may olny update Salary of PRESIDENT. !!');
--
- ELSE
- Do something you would do when updating
- salary of job president
--
END IF; END; /
Assuming you want to record any changes on sal of table emp, when the job is
not president...
Watch out with the error message: there's no stopping a clever hacker
from changing his/her job to president, up his/her salary, and change it back
again!
Cheers, Frank
Alex J wrote:
> Seems to me that this trigger will generate > "RAISE_APPLICATION_ERROR(-20500" every time unless you test the insert > via SQL%RowCount or something! > > James A. Johnson wrote in message <3686DC72.9D5287A5_at_bellsouth.net>... > >You need to provide a little more on this problem. Does it update the > >president or just the people not the president. Also see if the trigger > >is compiled and accurate using enterprise manager. > > > > > >"Kang, Dale" wrote: > > > >> Why this routine don't work ? > >> Please help me! > >> I really appreciate your reading. > >> > >> CREATE OR REPLACE TRIGGER get_hacker > >> BEFORE UPDATE OF sal ON emp > >> FOR EACH ROW > >> WHEN (old.job != 'PRESIDENT') > >> BEGIN > >> INSERT INTO guard(hacker, mod_date, old_sal, new_sal) > >> VALUES(user, > >> to_char(sysdate,'yy/mm/dd hh24:mi:ss'), > >> :old.sal, :new.sal); > >> > >> RAISE_APPLICATION_ERROR(-20500, > >> 'You may olny update Salary of PRESIDENT. !!'); > >> END; > >> / > >
--------------3CBE9E31A2FCDEF561153728
Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Is this what you're looking for?
<p><tt>CREATE OR REPLACE TRIGGER get_hacker</tt> <br><tt> BEFORE UPDATE OF sal ON emp</tt> <br><tt> FOR EACH ROW</tt> <br><tt>BEGIN</tt> <br><tt> IF (old.job <> 'PRESIDENT')</tt> <br><tt> THEN</tt> <br><tt> INSERT INTO guard (</tt> <br><tt> hacker</tt>
<br><tt> , mod_date</tt>
<br><tt> , old_sal</tt>
<br><tt> , new_sal )</tt>
<br><tt> VALUES (</tt> <br><tt> user</tt> <br><tt> , to_char(sysdate,'yy/mm/dd hh24:mi:ss')</tt> <br><tt> , :old.sal</tt>
<br><tt> , :new.sal )</tt>
<br><tt> ;</tt><tt></tt>
<p><tt> RAISE_APPLICATION_ERROR(-20500,</tt> <br><tt> 'You may olny update Salary of PRESIDENT. !!');</tt>
<br><tt>--</tt> <br><tt>-- ELSE</tt> <br><tt>-- Do something you would do when updating</tt> <br><tt>-- salary of job president</tt> <br><tt>--</tt> <br><tt> END IF;</tt> <br><tt>END;</tt> <br><tt>/</tt> <p>Assuming you want to record any changes on sal of table emp, when thejob is not president...
<br>Watch out with the error message: there's no stopping a clever hacker <br>from changing his/her job to president, up his/her salary, and change it back again!
<p>Cheers, Frank <br>Alex J wrote: <blockquote TYPE=CITE>Seems to me that this trigger will generate <br>"RAISE_APPLICATION_ERROR(-20500" every time unless you test the insert <br>via SQL%RowCount or something! <p>James A. Johnson wrote in message <3686DC72.9D5287A5_at_bellsouth.net>... <br>>You need to provide a little more on this problem. Does it updatethe
<br>>president or just the people not the president. Also see if the trigger
<br>>is compiled and accurate using enterprise manager. <br>> <br>> <br>>"Kang, Dale" wrote: <br>> <br>>> Why this routine don't work ? <br>>> Please help me! <br>>> I really appreciate your reading. <br>>> <br>>> CREATE OR REPLACE TRIGGER get_hacker <br>>> BEFORE UPDATE OF sal ON emp <br>>> FOR EACH ROW <br>>> WHEN (old.job != 'PRESIDENT') <br>>> BEGIN <br>>> INSERT INTO guard(hacker, mod_date, old_sal, new_sal) <br>>> VALUES(user, <br>>> to_char(sysdate,'yy/mm/ddhh24:mi:ss'),
<br>>> :old.sal, :new.sal);
<br>>> <br>>> RAISE_APPLICATION_ERROR(-20500, <br>>> 'You may olny update Salaryof PRESIDENT. !!');
<br>>> END; <br>>> / <br>></blockquote> </html>
--------------3CBE9E31A2FCDEF561153728--
Received on Tue Dec 29 1998 - 09:13:18 CET