Methods in pl/sql, PL-SQL Programming

Methods:

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

instance_expression.method()

Though, the STATIC methods are invoked on the object type, not its instance, as in

object_type_name.method()

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 (

top INTEGER,

MEMBER FUNCTION full RETURN BOOLEAN,

MEMBER PROCEDURE push (n IN INTEGER),

...

);

CREATE TYPE BODY Stack AS

...

MEMBER PROCEDURE push (n IN INTEGER) IS

BEGIN

IF NOT full THEN

top := top + 1;

...

END push;

END;

Posted Date: 10/6/2012 8:05:22 AM | Location : United States







Related Discussions:- Methods in pl/sql, Assignment Help, Ask Question on Methods in pl/sql, Get Answer, Expert's Help, Methods in pl/sql Discussions

Write discussion on Methods in pl/sql
Your posts are moderated
Related Questions
SQL Pseudocolumns The PL/SQL recognizes the following SQL pseudocolumns, that returns the specific data items: LEVEL, NEXTVAL, CURRVAL, ROWID, & ROWNUM. The Pseudocolumns are n

Name Resolution   During the compilation, the PL/SQL compiler relates identifiers like the name of a variable with an address or memory location, actual value, or datatype. Th

UNION ALL - SQL Further varieties of UNION arise when we replace the key word DISTINCT by ALL in any of the foregoing examples, as in Example. ALL specifies that if row r appe

MERGE and TRUNCATE in SQL SQL has two more table update operators, MERGE and TRUNCATE. MERGE, like INSERT, takes a source table s and uses it to update a target table t. Brief

At times, Brewbean's has changed the id number for existing products. In the past, they have had to add a new product row with the new id to the BB_PRODUCT table, modify all the co

Create a procedure named STATUS_SHIP_SP that allows a company to employee in the Shipping Department to update the status of an order to add shipping information. The BB_BASKETSTAT

(a) What are decision support systems, and what role do they play in the business environment? (b) Data warehousing is defined as "a subject-oriented, integrated, non-volatile c

%TYPE Attribute The %TYPE attribute gives the datatype of a record, field, nested table, database column, or the variable. You can use the %TYPE attribute as the datatype speci

Database Values You can use the SELECT statement to have the Oracle assign values to a variable. For Each and every item in the select list, there must be a matching, type-compa

NULL Statement The NULL statement clearly specifies in action; it does nothing other than to pass control to the next statement. It can, though, improve the readability. In a