Calling constructors in pl sql, PL-SQL Programming

Assignment Help:

Calling Constructors:

The Calls to a constructor are allowed wherever the function calls are allowed. Similarly to the functions, a constructor is called as a section of an expression, as the illustration below is a shown:

DECLARE

r1 Rational := Rational(2, 3);

FUNCTION average (x Rational, y Rational) RETURN Rational IS

BEGIN

...

END;

BEGIN

r1 := average(Rational(3, 4), Rational(7, 11));

IF (Rational(5, 8) > r1) THEN

...

END IF;

END;

Whenever you pass a parameter to a constructor, the call assigns its initial value to the attributes of the object being instantiated. You should supply a parameter for every attribute as, dissimilar constants and variables, the attributes cannot have the default values. As the illustration shown below, the nth parameter assigns a value to the nth attribute:

DECLARE

r Rational;

BEGIN

r := Rational(5, 6); -- assign 5 to num, and 6 to den

-- now r is 5/6

The later illustration shows that you can call a constructor using the named notation rather than that of the positional notation:

BEGIN

r := Rational(den => 6, num => 5); -- assign 5 to num, and 6 to den


Related Discussions:- Calling constructors in pl sql

Parameter and keyword description - sql cursor, Parameter and Keyword Descr...

Parameter and Keyword Description: SQL: This SQL is the name of the implicit SQL cursor. %FOUND: This attribute results TRUE if an INSERT, DELETE, or UPDATE state

Mutual recursion, Mutual Recursion The Subprograms are mutually recursi...

Mutual Recursion The Subprograms are mutually recursive if they directly or indirectly call each other. In the illustration below, the Boolean functions odd & even, that dete

Methods in pl/sql, Methods: In normal, a method is a subprogram declar...

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 typ

Effects of null, Effects of NULL The numeric variable X, perhaps of ty...

Effects of NULL The numeric variable X, perhaps of type INTEGER, might be assigned NULL. In that case the result of evaluating X + 1 is NULL, and so SET Y = X + 1 assigns NULL

Use native dynamic sql - improve performance of application, Use Native Dyn...

Use Native Dynamic SQL A few programs (a normal-purpose report writer for illustration) should build and process a variety of SQL statements at run time. Therefore, their full

Semijoin and composition - sql, Semijoin and Composition - SQL For sem...

Semijoin and Composition - SQL For semijoin, the dyadic relational operator MATCHING, defined thus: r1 MATCHING r2, where r1 and r2 are relations such that r1 JOIN r2 is de

Join and and in sql, JOIN and AND in SQL In this Section is all about ...

JOIN and AND in SQL In this Section is all about one operator, JOIN. SQL's closest counterpart, NATURAL JOIN, has already been covered. Here we look at several other "join" op

Package dbms output in pl/sql, DBMS_OUTPUT: The Package DBMS_OUTPUT en...

DBMS_OUTPUT: The Package DBMS_OUTPUT enables you to display output from the PL/SQL subprograms and blocks, that makes it easier to test and debug them. The procedure put_ line

Fetching with a cursor, Fetching with a Cursor The FETCH statements re...

Fetching with a Cursor The FETCH statements retrieve the rows in the result set one at a time. After each and every fetch, the cursor advance to the next row in the result set

Using exists - collection methods, Using EXISTS The EXISTS(n) returns ...

Using EXISTS The EXISTS(n) returns TRUE if the nth element in a collection exist. Or else, EXISTS(n) returns FALSE. Primarily, you use EXISTS with DELETE to maintain the spars

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