Thursday, March 3, 2011

Function overloading by datatype of parameters

SET SERVEROUTPUT ON

DECLARE
     FUNCTION getArea(v_radious NUMBER, v_precision NUMBER) RETURN NUMBER IS
     l_pi NUMBER := 3.14;
     BEGIN
          RETURN TRUNC((l_pi *(v_radious ** 2)),v_precision);
     END;
     FUNCTION getArea(v_radious NUMBER ,v_ignore CHAR) RETURN NUMBER IS
     BEGIN
          IF v_ignore = 'Y' THEN
             RETURN 0;
          ELSE
             RETURN (3.14 *(v_radious ** 2));
          END IF;
     END;
BEGIN
     DBMS_OUTPUT.PUT_LINE('Area of Circle is '|| getArea(6.4, 2));
     DBMS_OUTPUT.PUT_LINE('Area of Rectangle is '|| getArea(6,'N'));
END;

No comments:

Post a Comment

External Table

Oracle External Table External tables are defined as tables that do not resides in the database allows you to access data that is stor...