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
Declarations in SQL Your program stores values in the variables and constants. As the program executes, the value of the variables can change, but the values constants cannot.

Define basic operators of relational algebra with an example each

a. Create a table odetails_new. It has all the attributes of odetails and an additional column called cost, whose values are the product of the quantity and price of the part bein

Using a Host Variable You can declare the cursor variable in the PL/SQL host environment like an OCI or Pro C program. To use the cursor variable, you should pass it as a host

First Step at defining type SID in SQL CREATE TYPE SID AS ( C VARCHAR(5) ) ; Explanation: TYPE SID announces that a type named SID is being defined to the syst

PRIMARY KEY: PRIMARY KEY  indicates that the table is subject to a key constraint, in this case declaring that no two rows in the table assigned to ENROLMENT can ever have the

Order of Evaluation When you do not use the parentheses to specify the order of evaluation, the operator precedence determine the order. Now compare the expressions below: NOT

Project Description: We organize an online system called ACPAS we have created a project called EVO that can be use by our customers to integrate their web sites with the Acpas

Opening a Cursor Variable The OPEN-FOR statement relates a cursor variable with the multi-row query, executes the query, and then identifies the result set. The syntax for ope

Implicit Rollbacks Before execute the INSERT, UPDATE, or DELETE statement, the Oracle marks an implicit savepoint . When the statement fails, the Oracle rolls back to the save