12 Replies Latest reply: May 27, 2013 10:15 AM by Mac_Freak_Rahul RSS

    Simple Trigger question

    Mac_Freak_Rahul
      Hi All,

      My oracle database version : 10G

      I have the following code on my employees table, lets say I fire an update on my employees table and in return 6 rows gets updated, I want to print this number within my trigger on the console, I have put a comment in my code where I want to achieve this.

      <code>
      create or replace trigger trig_employees_au
      after update on employees
      declare
           Linst_file utl_file.file_type;
      begin
           if updating
           then
                if sql%found -- need to print the number of affected rows.
                then
                     dbms_output.put_line('Affected rows : '||sql%rowcount);
                end if;
                     dbms_output.put_line('An update has just occoured on this table.');
                     Linst_file := utl_file.fopen('PLSQL','FILE_WATCH.txt','w');
                     utl_file.put_line(Linst_file,'Updated');
                     utl_file.fclose(Linst_file);
           end if;
      end;

      </code>

      Regards
      Rahul