In normal, a method is a subprogram declared in an object type specification using the keyword MEMBER or STATIC. The method cannot have similar name as the object type or any of its attributes. The MEMBER methods are invoked on instances, as in the
Though, the STATIC methods are invoked on the object type, not its instance, as in
Similar packaged subprograms, many methods have 2 parts: the specification and the body. The specification consists of an optional parameter list, a method name, and, for functions, the return type. The body is a code that executes to perform the specific task.
For each method specification in an object type specification, there should be a corresponding method body in the object type body. To match the method specifications & bodies, the PL/SQL compilers do a token-by-token comparison of their headers. Therefore, the headers should match the word for word.
In an object type, the methods can reference the attributes and another method without a qualifier, as the illustration below shows:
CREATE TYPE Stack AS OBJECT (
MEMBER FUNCTION full RETURN BOOLEAN,
MEMBER PROCEDURE push (n IN INTEGER),
CREATE TYPE BODY Stack AS
MEMBER PROCEDURE push (n IN INTEGER) IS
IF NOT full THEN
top := top + 1;