SQL>
SQL> -- The emptype function.
SQL> CREATE OR REPLACE FUNCTION emptype (paytype CHAR)
2 RETURN VARCHAR2 IS
3 BEGIN
4 IF paytype = 'H' THEN
5 RETURN 'Hourly';
6 ELSIF paytype = 'S' THEN
7 RETURN 'Salaried';
8 ELSIF paytype = 'E' THEN
9 RETURN 'Executive';
10 ELSE
11 RETURN 'Invalid Type';
12 END IF;
13 EXCEPTION
14 WHEN OTHERS THEN
15 RETURN 'Error Encountered';
16 END emptype;
17 /
Function created.
SQL>
SQL> select emptype('H') from dual;
EMPTYPE('H')
---------------------------------------------------------------------
Hourly
SQL>
SQL> select emptype('S') from dual;
EMPTYPE('S')
---------------------------------------------------------------------
Salaried
SQL>
SQL> select emptype('E') from dual;
EMPTYPE('E')
---------------------------------------------------------------------
Executive
SQL>
|