Static Methods v13
Like a member method, a static method belongs to a type. A static method, however, is invoked not by an instance of the type, but by using the name of the type. For example, to invoke a static function named get_count
, defined within the emp_obj_type type
, you can write:
emp_obj_type.get_count();
A static method does not have access to, and cannot change the attributes of an object instance, and does not typically work with an instance of the type.
The following object type specification includes a static function get_dname
and a member procedure display_dept:
CREATE OR REPLACE TYPE dept_obj_typ AS OBJECT ( deptno NUMBER(2), STATIC FUNCTION get_dname(p_deptno IN NUMBER) RETURN VARCHAR2, MEMBER PROCEDURE display_dept );
The object type body for dept_obj_typ
defines a static function named get_dname
and a member procedure named display_dept: