This script demonstrates the static method. : Object Method « Object Oriented Database « Oracle PL / SQL






This script demonstrates the static method.

   
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>

   
    
    
  








Related examples in the same category

1.Creating User-defined Functions for Column Objects
2.Use method from object in select command
3.Access member variable in member function in a type
4.Compare two type object instances
5.A sample object type with a MAP member function
6.A sample object type with an ORDER member function.
7.This script builds a sample object type with member variables and functions
8.This script demonstrates the order method.
9.Type with member procedure
10.Demonstrates the member method.