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;

Answers were Sorted based on User's Feedback



Hi All, I am new to both this blog and technology. I was able to see a response for one of the ..

Answer / 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

Hi All, I am new to both this blog and technology. I was able to see a response for one of the ..

Answer / 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

More SQL PLSQL Interview Questions

What are different methods to trace the pl/sql code?

0 Answers  


What is meant by truncate in sql?

0 Answers  


What are the different sql languages?

0 Answers  


Does oracle roll back the transaction on an error?

0 Answers  


What is graph sql?

0 Answers  






What does subquery mean in sql?

0 Answers  


What are the triggers associated with image items?

0 Answers  


Does truncate remove indexes?

0 Answers  


What is the best free sql database?

0 Answers  


hi..........i m Accenture employee...Accenture is an IT company having itz branches in India at Mumbai, Pune,Delhi, Hyderabad, Chennai and Bangalore....Presently there are openings here for SAP, Testing, Oracle,Java,.NET,MAinframe and Peoplesoft...... I am a software engineer working with Accenture,Mumbai....u can mail me in your resume..i`ll forward it to our HR team...my mail id: pankit.lodaya@accenture.com

8 Answers   Wipro,


what is the difference difference between procedure and packages

2 Answers   3i Infotech, Oracle,


What are the properties of a transaction?

0 Answers  


Categories