Components of an object type - parameter self, PL-SQL Programming

Assignment Help:

Parameter SELF in pl/sql

The MEMBER methods recognize a built-in parameter named SELF that is an instance of the object type. Whether declared explicitly or implicitly, it is forever the first parameter passed to the MEMBER method. Though, the STATIC methods cannot accept or reference SELF.

In the method body, the SELF represents the object whose method was invoked. For illustration, the method transform declares SELF as an IN OUT parameter:

CREATE TYPE Complex AS OBJECT (

MEMBER FUNCTION transform (SELF IN OUT Complex) ...

You cannot specify a unlike datatype for SELF. In the MEMBER functions, if SELF is not declared, its parameter mode defaults to IN. Though, in the MEMBER procedures, if SELF is not declared then its parameter mode defaults to IN OUT. You can't specify the OUT parameter mode for SELF. As the illustration below shows, the methods can reference the attributes of SELF lacking a qualifier:

CREATE FUNCTION gcd (x INTEGER, y INTEGER) RETURN INTEGER AS

-- find maximum common divisor of x and y

ans INTEGER;

BEGIN

IF (y <= x) AND (x MOD y = 0) THEN ans := y;

ELSIF x < y THEN ans := gcd(y, x);

ELSE ans := gcd(y, x MOD y);

END IF;

RETURN ans;

END;

CREATE TYPE Rational AS OBJECT (

num INTEGER,

den INTEGER,

MEMBER PROCEDURE normalize,

...

);

CREATE TYPE BODY Rational AS

MEMBER PROCEDURE normalize IS

g INTEGER;

BEGIN

g := gcd(SELF.num, SELF.den);

g := gcd(num, den); -- equivalent to previous statement

num := num / g;

den := den / g;

END normalize;

...

END;

From the SQL statement, if you call a MEMBER method on a null instance, the method is not invoked and a null is returned. From the procedural statement, when you call the  MEMBER method on a null instance, the PL/SQL raises the predefined exception SELF_IS_NULL before the method is invoked.


Related Discussions:- Components of an object type - parameter self

Dbms, DBMS: The answer to this question is of course given in of the t...

DBMS: The answer to this question is of course given in of the theory book. This book is concerned with SQL DBMSs and SQL databases in particular. Soon we will be looking a

Comparison operators - sql operators, Comparison Operators Usually, yo...

Comparison Operators Usually, you use the comparison operators in the WHERE clause of a data manipulation statement to form the predicates, that compare one expression to anot

Solve the business problems using sql, Use the MASCOT tables CREDITRS, PORD...

Use the MASCOT tables CREDITRS, PORDS and PAYMENTS to write SQL queries to solve the following business problems. These tables / data are available to you via the USQ Oracle server

How bulk bind helps improvement in performance?, How Bulk Binds Improve Per...

How Bulk Binds Improve Performance The assigning of values to the PL/SQL variables in SQL statements is known as binding. The binding of the whole collection at once is know

Functions in pl/sql, Functions   The function is a subprogram that cal...

Functions   The function is a subprogram that calculates a value. The Functions and procedures are structured similar, except that the functions have a RETURN clause. You can

Theory of eternity of life - origin of life, THEO R Y OF ETERNITY OF LIFE...

THEO R Y OF ETERNITY OF LIFE (PRAYER - 1880) - The theory of eternity of life, also called the steady-state theory , states that life has ever been in existence as at presen

Relational operators and logical operators, Relational Operators and Logica...

Relational Operators and Logical Operators It prepares the ground for subsequent sections in which each specific relational operator is paired with its logical counterpart, su

Use external routines - improve performance of application, Use External Ro...

Use External Routines The PL/SQL is particular for the SQL transaction processing. Therefore, several tasks are more quickly completed in a lower-level language like C that is

Important distinctions, Important Distinctions The list of important d...

Important Distinctions The list of important distinctions are given below: Value versus variable Syntax versus semantics Variable versus variable reference

Mysql developer/programmer, Project Description: I want somebody who can...

Project Description: I want somebody who can help me with an idea that I have been working on for a few months now. The person will require extensive knowledge of warcraft 3 PvP

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd