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
What is the current version of sql?
Write a program that shows the usage of while loop to calculate the average of user entered numbers and entry of more numbers are stopped by entering number 0?
What is sql*plus?
What is the default isolation level in sql server? : Transact sql
what is a materialized view? : Sql dba
Can we commit in trigger?
Why join is faster than subquery?
What is rank function in sql?
What is mutating error?
what does it mean to have quoted_identifier on? What are the implications of having it off? : Sql dba
What is your daily office routine?
What are the ways on commenting in a pl/sql code?
What is the benefit of foreign key?
what is a database transaction? : Sql dba
What is a sql trace file?