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 are conditional predicates?

692


What is difference between sql and excel?

592


Is sql a programming?

634


Why having clause is used in sql?

637


How do you clear the screen in sql?

688






What is execute immediate?

634


what are the different type of sql's statements ? : Sql dba

614


What is a memo field?

618


What is union and union all keyword in sql and what are their differences?

694


What are the two types of exceptions.

719


List the various privileges that a user can grant to another user?

671


What are the advantages of normalization?

662


what are different types of collation sensitivity? : Sql dba

661


Explain what is a field in a database and record in a database?

692


What is attribute indicator in pl sql?

616