This script demonstrates the static method. : Member Function « Object Oriented « Oracle PL/SQL Tutorial






SQL>
SQL> SET SERVEROUTPUT ON SIZE 1000000
SQL>
SQL>
SQL> CREATE OR REPLACE TYPE PriceType AS OBJECT (
  2     discount_rate   NUMBER (10, 4),
  3     price           NUMBER (10, 2),
  4     STATIC FUNCTION new_price (p_price IN NUMBER,rebate IN NUMBER DEFAULT .1)
  5        RETURN NUMBER
  6  )
  7  INSTANTIABLE FINAL;
  8  /

Type created.

SQL>
SQL> CREATE OR REPLACE TYPE BODY PriceType
  2  AS
  3     STATIC FUNCTION new_price(p_price IN NUMBER,rebate IN NUMBER DEFAULT .1)
  4        RETURN NUMBER
  5     IS
  6     BEGIN
  7        RETURN (p_price * (1 - rebate));
  8     END new_price;
  9  END;
 10  /

Type body created.

SQL>
SQL> -- exec DBMS_OUTPUT.PUT_LINE(PriceType.new_price(75));
SQL>








32.3.Member Function
32.3.1.Type with member function
32.3.2.Call Object member function
32.3.3.Type with toString and mapping functions
32.3.4.A sample object type with a MAP member function
32.3.5.A sample object type with an ORDER member function.
32.3.6.This script demonstrates the static method.
32.3.7.Compare two type object instances
32.3.8.This script builds a sample object type with constructor.