-2

I am having an issue to create Trigger I am attaching a photo of my cmd bellow

enter image description here

This is my code

CREATE OR REPLACE TRIGGER display_salary_changes
BEFORE DELETE OR INSERT OR UPDATE ON customers 
FOR EACH ROW
WHEN (NEW.ID > 0)
DECLARE
    sal_diff number;
BEGIN
    sal_diff := :NEW.salary - :OLD.salary;
    dbms_output.put_line('Old salary ' || :OLD.salary);
    dbms_output.put_line('New salary ' || :NEW.salary);
    dbms_output.put_line('Salary difference ' || :sal_diff);
END;
/

ERROR

ORA-04089: cannot create triggers on objects owned by SYS

what will be the possible solution for this or what will I do now please give me some suggestion

Pronab Roy
  • 1,058
  • 1
  • 14
  • 18

1 Answers1

1

I think your customer table created by SYS user.

Create an user using sys like 'MY_USER' connect with it then create your customer table with MY_USER. And try create your trigger. Drop sys.customer table.

This account can perform all administrative functions. All base (underlying) tables and views for the database data dictionary are stored in the SYS schema. These base tables and views are critical for the operation of Oracle Database. To maintain the integrity of the data dictionary, tables in the SYS schema are manipulated only by the database. They should never be modified by any user or database administrator. You must not create any tables in the SYS schema.

According: https://docs.oracle.com/database/121/ADMQS/GUID-CF1CD853-AF15-41EC-BC80-61918C73FDB5.htm#ADMQS12003

mehmet sahin
  • 802
  • 7
  • 21