-1

Trying to get Oracle to Get a date set it to year only and compare to a value inserted or updated into my database before hand This is what I have tried so far. But I seem to be stuck Any assistance would be great, Thanks

create or replace
TRIGGER CHECK_YEAR_DIFF
BEFORE INSERT OR UPDATE OF YEAROFPERSON ON PERSON 
FOR EACH ROW 

Currentdate Date; 
Playeryrborn_Var Integer;

Begin

Currentdate := TRUNC(Sysdate,'YYYY');
YEAROFPERSON_var := new.YEAROFPERSON;

  IF (currentDate - YEAROFPERSON_var <= 40) AND (currentDate - YEAROFPERSON_var => 16) THEN 

  dbms_Output.Put_Line('Year of Birth Updated Successfully');

  ELSE

  dbms_output.put_line('Year of Birth Failed to Successfully Update');

  END IF;

END;
4

2 回答 2

0

我认为您需要更改行: currentDate - YEAROFPERSON_var <= 40

至:

cast(to_char(sysdate, 'YYYY') as int) - YearOfPerson_Var <= 40
于 2012-05-22T13:52:32.717 回答
0

IF (currentDate - YEAROFPERSON_var <= 40) AND (currentDate - YEAROFPERSON_var => 16)

替换为以下内容

IF (currentDate - YEAROFPERSON_var <= 40) AND (currentDate - YEAROFPERSON_var >= 16)

于 2012-05-23T09:54:01.230 回答