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

Hi,

see the below example you can easily understand that why we are using trim.

select decode(TRIM(to_char(SYSDATE,'Day')),'Monday','3','1') from dual


1. select decode(to_char(SYSDATE,'Day'),'Monday','3','1') from dual
Ans : 1 – error because eroju Monday ne kabatti query 3 return cheyali kani 1 return chesthundi. Karanam spaces so we need to use trim function.enduko kinda points chudu

2. Run this query and check the output select to_char(SYSDATE,'Day') from dual
3. select length(to_char(SYSDATE,'Day')) from dual  –- ee query run chei output 9 vasthundi. But Monday actual length is 6.


run these queries

Is This Answer Correct ?    4 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Mention what does plvtab enables you to do when you showthe contents of pl/sql tables?

661


How do I find duplicates in the same column?

526


How do I count records in sql?

508


Explain 3 basic parts of a trigger.

826


Is there a pl/sql pragma similar to deterministic, but for the scope of one single sql select?

527






Why do we use subquery?

481


What is the primary use of normalization?

520


Why do we need databases?

559


Does sap use sql?

513


Why do we use procedures in sql?

542


What is hibernate and its relation to sql?

587


What is java sql connection?

508


What is pl sql record in oracle?

558


Can we create foreign key without primary key?

527


Which operator is used in query for pattern matching?

617