Calling constructors in pl sql, PL-SQL Programming

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:


r1 Rational := Rational(2, 3);

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





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

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




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:


r Rational;


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:


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

Posted Date: 10/6/2012 8:15:20 AM | Location : United States

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

Write discussion on Calling constructors in pl sql
Your posts are moderated
Related Questions
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

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

Collections:   The collection is an ordered group of elements, all of similar type (for illustration, the grades for a class of students). Each element has an exclusive subsc

Benefit of the dynamic SQL: This part shows you how to take full benefit of the dynamic SQL and how to keep away from some of the common pitfalls. Passing the Names of Sc

%ROWCOUNT When its cursor or cursor variable is opened, the %ROWCOUNT is zeroed. Before the first fetch, the %ROWCOUNT yields 0. Afterward, it yields the number of rows fetche

Deriving Predicates from Predicates in SQL The corresponding section in the theory book describes how predicates can be derived from predicates using (a) the logical connectiv

Subprograms The PL/SQL has two types of subprograms known as the procedures and functions that can take parameters and be invoked. As the following example represents, a subp

Information Hiding   With the information hiding, you see only the details that are significant at a given level of algorithm and data structure design. The Information hiding

PPD , CPA, Filesharing Site Project Description: This is very easy I need a PPD , CPA, Filesharing Site. [PPD] stands for (pay per download) example hotsharecash [Files

Parameter and Keyword Description: label_name: This is an undeclared identifier which optionally labels a loop. When used, the label_name should be enclosed by double ang