views:

659

answers:

3

I'm Learning Oracle and wanted to try creating a trigger. I tried this example form a book in sqlplus.

SQL> CREATE OR REPLACE TRIGGER policy_bull BEFORE insert or update
  2  ON emp
  3  FOR EACH ROW
  4  BEGIN
  5    :new.salary := 200;
  6  END
  7  /

ERROR at line 1: ORA-04089: cannot create triggers on objects owned by SYS

even though I logged in as SYS using

sqlplus "sys/oracle as sysdba"

+1  A: 

You need to type / on a blank line to tell SQLPLUS to run the statement.

Jeffrey Kemp
I see you've edited your question to include the / now.
Jeffrey Kemp
+3  A: 

Oracle forbids creating triggers on objects owned by SYS.

Did you create the table emp as SYS? You probably want to be a regular user to do that. emp doesn't sound like a system table.

UncleO
good catch. It looks like someone may have run the example tables ("emp" is a table in the standard examples schema) while they were logged in as SYS.
Jeffrey Kemp
A: 

I think a semi-colon is missing after END. Also mention SYS.emp