-1

I've just started working with Triggers. While trying to compile the next code fragment errors are listed in the log, like so: "Error(2,3): PL/SQL: SQL Statement ignored" and "Error(2,7): PL/SQL: ORA-00922: missing or invalid option". I don't understand the problem. Can anybody help?

CREATE OR REPLACE TRIGGER CONT_VIG
BEFORE INSERT ON CONTRACTS
FOR EACH ROW
WHEN (OLD.CLIENTID = NEW.CLIENTID AND OLD.ENDDATE > NEW.STARTDATE)

BEGIN
SET (OLD.enddate = :NEW.startdate-1);    
END;  
MT0
  • 143,790
  • 11
  • 59
  • 117
  • `FOR EACH ROW` means for each row inserted - not for each row that exists in the table pre-insert. – MT0 Apr 19 '17 at 11:32
  • https://docs.oracle.com/database/121/LNPLS/create_trigger.htm lots of examples provided in the docs – kayakpim Apr 19 '17 at 11:33
  • [Is this for the same assignment?](http://stackoverflow.com/q/43483253/266304) – Alex Poole Apr 19 '17 at 11:42
  • First explain what are you trying to do - we cannot really comment on a code if we have no idea what are the requirements. – Goran Stefanović Apr 19 '17 at 13:31
  • Where in the [PL/SQL manual](https://docs.oracle.com/database/121/LNPLS/fundamentals.htm#LNPLS00205) did you find the `SET` to assign values? –  Apr 19 '17 at 13:40

2 Answers2

0

look this this-oracle and this-stackoverflow

try this:

CREATE TRIGGER hr.salary_check
      BEFORE INSERT OR UPDATE OF salary, job_id ON hr.employees
      FOR EACH ROW
         WHEN (new.job_id <> 'AD_VP')
      pl/sql_block
Community
  • 1
  • 1
CompEng
  • 7,161
  • 16
  • 68
  • 122
0

You can't change OLD value...

replace

SET (OLD.enddate = :NEW.startdate-1);    

with for example :

:NEW.startdate := sysdate ;

(I removed SET because I don't see the usefulness)