Your Location is: Home > Sql

How to get all the old and new Values without specifying explicitly giving column names?

From: Luxembourg View: 3678 Aashish Pawar 

Question

I have a table with some values. I wrote a trigger on that table as follows.

CREATE OR REPLACE TRIGGER display_changes 
After DELETE OR INSERT OR UPDATE 
ON users 
FOR EACH ROW 
WHEN (NEW.ID > 0) 
BEGIN 
  dbms_output.put_line('Old values: ' || :OLD.id); 
  dbms_output.put_line('New values: ' || :NEW.id);
  --  column2
  dbms_output.put_line('Old values: ' || :OLD.name); 
  dbms_output.put_line('New values: ' || :NEW.name);
   -- column3
  dbms_output.put_line('Old values: ' || :OLD.address); 
  dbms_output.put_line('New values: ' || :NEW.address);
   -- for all columns 
END; 

So what I'm asking, Is there any better way to do it? Like using * operator with :OLD and :NEW variable. Or something better approach without specifying all the columns ?

thanks.

Best answer