Mega Code Archive

 
Categories / Oracle PLSQL Tutorial / PL SQL Statements
 

Using an ELSIF Statement

SQL> SQL> create or replace function f_getDateType (in_dt DATE)   2  return VARCHAR2   3  is   4      v_out VARCHAR2(10);   5  begin   6      if to_char(in_dt,'MMDD') in ('0101','0704') then   7          v_out:='HOLIDAY';   8      elsif to_char(in_dt,'d') = 1 then   9          v_out:='SUNDAY';  10      elsif to_char(in_dt,'d') = 7 then  11          v_out:='SATURDAY';  12      else  13          v_out:='WEEKDAY';  14      end if;  15      return v_out;  16  end;  17  / Function created.