Skip to Main Content

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Gyanaranjan.

Asked: August 07, 2016 - 5:52 am UTC

Last updated: August 07, 2016 - 7:21 am UTC

Version: 11g

Viewed 1000+ times

You Asked

create or replace trigger foremp
before insert on emp
declare
day char(10);
begin
if (to_char(sysdate,day) in ('sunday')) then
raise_application_error(-20300,'not allowed on sunday');
end if;
end;
/ I created this trigger to avoid insert on emp table on sunday. But it takes value on sunday also. What is the mistake tell please.

thank u.

and Connor said...

SQL> select 'x'||to_char(sysdate,'DAY')||'x' from dual;

'X'||TO_CHA
-----------
xSUNDAY   x


The DAY format mask is padded.

Is this answer out of date? If it is, please let us know via a Comment

More to Explore

PL/SQL demos

Check out more PL/SQL tutorials on our LiveSQL tool.

PL/SQL docs

PL/SQL reference manual from the Oracle documentation library