set serveroutput on;
create or replace trigger check_date
before insert
on emp
for each row
begin
dbms_output.put_line('test statement'||:new.hiredate||sysdate); --to test display
if(:new.hiredate<sysdate) then
dbms_output.put_line('invalid');
end if;
end;
/
insert into emp(empno,deptno,hiredate) values(533,20,'23-3-12');
I have written the above trigger but when i try to insert a new record into emp table,the record is inserted without firing the trigger.
'23-3-12'is a string, not a date; implicit conversion might get the value you want but isn't safe. Explicit conversion or a date literal is safer - e.g.DATE '2012-03-23') - Alex Poole