SQL> set serveroutput on
SQL> set echo on
SQL>
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> BEGIN
2 DBMS_OUTPUT.PUT_LINE('emptype ' || emptype('H'));
3 DBMS_OUTPUT.PUT_LINE('emptype ' || emptype('S'));
4 DBMS_OUTPUT.PUT_LINE('emptype ' || emptype('E'));
5 DBMS_OUTPUT.PUT_LINE('emptype ' || emptype('A'));
6 END;
7 /
emptype Hourly
emptype Salaried
emptype Executive
emptype Invalid Type
PL/SQL procedure successfully completed.
SQL>
SQL>
SQL>
|