Oracle PL/SQL - Write program to return 'SATURDAY', 'SUNDAY', or 'WEEKDAY' using IF...ELSIF statement

Requirements

Return one of the following results: 'SATURDAY', 'SUNDAY', or 'WEEKDAY'.

Hint

Demo

SQL>
SQL> create or replace function f_getDateType_tx (in_dt DATE)
  2  return VARCHAR2--  w w  w  .  jav a 2  s .com
  3  is
  4       v_out_tx VARCHAR2(10);
  5  begin
  6       if to_char(in_dt,'d') = 1 then
  7            v_out_tx:='SUNDAY';
  8       elsif to_char(in_dt,'d') = 7 then
  9            v_out_tx:='SATURDAY';
 10       else
 11            v_out_tx:='WEEKDAY';
 12       end if;
 13       return v_out_tx;
 14  end;
 15  /

Function created.

SQL> begin
  2     DBMS_OUTPUT.put_line(f_getDateType_tx(SYSDATE));
  3  end;
  4  /
SATURDAY

PL/SQL procedure successfully completed.
SQL>

Related Exercise