Hi All,

I am new to both this blog and technology. I was able to
see a response for one of the questions on triggers as
below.

I would like to know why are we using
" if rtrim(to_char(sysdate,'day'))=rtrim('sunday') then"
instead, can't we use
" if sysdate = 'sunday' then".

I can understand the use of "rtrim", but dont know y v r
using to_char. I have seen this in many cases but did not
get a convincible explaination.

Please help me with this and do excuse if this question
sounds silly.

Thanks in advance......

create or replace trigger trg_sun
before insert on <table name>
begin
if rtrim(to_char(sysdate,'day'))=rtrim('sunday') then
raise_application_error(-20345,'no transaction in sunday');
end if;
end trg_sun;

Answer Posted / eshwer

Run this query and check the result you can easyly understand y we used trim function..

select length(to_char(sysdate,'day')), length(rtrim(to_char(sysdate,'day'))) from dual;

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the purpose of design view?

518


How do I count rows in sql?

553


What is on delete set null?

557


Can you call pl/sql package functions from within a fast formula?

560


How do you create a unique index?

565






What is the difference between clustered and non-clustered indexes?

596


Is it mandatory for the primary key to be given a value when a new record is inserted?

702


What is the max nvarchar size?

512


Do we need to rebuild index after truncate?

520


What is equi join in sql?

604


what is heap table? : Sql dba

601


How do I count rows in sql query?

487


What is the difference between having and a where in sql?

567


What is coalesce in sql?

553


what are all types of user defined functions? : Sql dba

540