1 Reply Latest reply: May 4, 2013 2:21 PM by O.Developer RSS

    while updating the values it should come in the next row by using trigger..

    1007067
      Hi

      I want to update the salary in employees database and it should fires(trigger) on the the (emp history) table
      and it should return on the next row of the emphistory table not on the same row.

      Please give me the answer

      Edited by: 1004064 on May 4, 2013 2:50 AM
        • 1. Re: while updating the values it should come in the next row by using trigger..
          O.Developer
          HI

          In order to get what you want, let us take Scott schema,


          Create emp blok with 5 records.
          In pre-update trigger write the below code:
          DECLARE
          old_sal NUMBER;
          new_sal NUMBER := :emp.sal;
          oper_desc VARCHAR2(80);
          cursor emp_o_sal is select sal from emp
          WHERE empno = :emp.empno;
          BEGIN
          Open Emp_O_sal ;
          fetch emp_o_sal into old_sal;
          close emp_o_sal;

          If old_sal <> new_sal then
               
               Message('Insert into history table - Your insert statement without commit-Emp NO' ||:Emp.Empno);
          Else
               MessagE('Salary not changed for emp '||:emp.empno);
               
          End If;

          End ;

          ----------That is all , try if not getting post the result here
          https://docs.google.com/file/d/0B6k7l8hLvpK2RW1TYWU1WVdkOXc/edit


          1004064 wrote:
          Hi

          I want to update the salary in employees database and it should fires(trigger) on the the (emp history) table
          and it should return on the next row of the emphistory table not on the same row.

          Please give me the answer

          Edited by: 1004064 on May 4, 2013 2:50 AM