Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Function to RETURN BOOLEAN

BeefStuJan 2 2023

Happy new year all. I have the following functions, which appears to work fine. When I change it to try and RETURN a BOOLEAN it doesn't compile.

How can I change the function to return a BOOLEAN (Y OR N). Thanks to all who respond.

 create or replace function is_weekend (par_date in date) RETURN VARCHAR2 is
    begin
     return case when to_char(par_date, 'fmDAY', 'nls_date_language = english') in  ('SATURDAY', 'SUNDAY')
                  then
                       'Y'
                  else 'N'
             end;
    end;
/

 select rownum, trunc(sysdate) -10 + rownum as dt, is_weekend(trunc(sysdate) -10 + rownum) as weekend 
   from dual
   connect by level <= 20;
This post has been answered by mathguy on Jan 2 2023
Jump to Answer
Comments
Post Details
Added on Jan 2 2023
5 comments
1,632 views