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
Product-specific Packages The Oracle and different Oracle tools are supplied with the product-specific packages which help you to build the PL/SQL-based applications. For illu

Transactions in SQL BEGIN TRANSACTION, COMMIT, and ROLLBACK, SQL has the same syntax except for START in place of BEGIN. However, START TRANSACTION is used only for outermost

%NOTFOUND The %NOTFOUND is the logical opposite of the %FOUND. The %NOTFOUND yields TRUE when an INSERT, UPDATE, or DELETE statement affected no rows, or the SELECT INTO state

Example of COALESCE operator Example: Give the total of marks for each exam (simplified solution) SELECT CourseId, COALESCE ((SELECT SUM (Mark) FROM EXAM_MARK AS EM

Example of Foreign Key Constraint Example: Alternative formulation for 6.3 as a foreign key constraint ALTER TABLE EXAM_MARK ADD CONSTRAINT Must_be_enrolled_to_take_exam

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

%ISOPEN The %ISOPEN yields TRUE if its cursor or cursor variable is open; or else, the %ISOPEN yields FALSE. In the illustration, you use the %ISOPEN to select an action:

Forward Declarations The PL/SQL needs that you declare an identifier before using it. And hence, you should declare a subprogram before calling it. For illustration, the decla

Advantages of Subprograms The Subprograms give extensibility; that is, tailor the PL/SQL language to suit your requirements. For illustration, if you require a procedure which

IS NULL Operator The IS NULL operator returns the Boolean value TRUE whenever its operand is null or FALSE if it is not null. The comparisons including the nulls always yield NU