IF TRIM(l_day_of_week) in ('Monday','Tuesday','Wednesday',
'Thursday','Friday','Saturday')
The type of the return type is the default CHAR(9)..
9 - maximum length of the day of the week (Thursday)
So to Mondaybe added with spaces !! If you are not usingFMDAY
So, it TRIM()will delete all the filled spaces!
You can try the demo below using 'FM' ( Format Mask )
Without FM
SQL> select to_char(sysdate+level,'Day'),length(to_char(sysdate+level,'Day')) as length from dual
2 connect by level <= 7;
TO_CHAR(SYSDATE+LEVEL,'DAY') LENGTH
------------------------------------ ----------
Tuesday 9
Wednesday 9
Thursday 9
Friday 9
Saturday 9
Sunday 9
Monday 9
7 rows selected.
With FM
SQL> select to_char(sysdate+level,'FMDAY'),length(to_char(sysdate+level,'FMDaY')) as length from dual
2 connect by level <= 7;
TO_CHAR(SYSDATE+LEVEL,'FMDAY') LENGTH
------------------------------------ ----------
TUESDAY 7
WEDNESDAY 9
THURSDAY 8
FRIDAY 6
SATURDAY 8
SUNDAY 6
MONDAY 6
7 rows selected.
Finally,
l_day_of_week = to_char(sysdate,'DaY')
Would you save a dynamic SQL call!