Initializing objects in pl sql, PL-SQL Programming

Initializing Objects:

Till you initialize an object by calling the constructor for its object type, the object is automatically null. That is, the object itself is null, not merely its attributes. Consider the

Illustration which is as shown:

DECLARE

r Rational; -- r become atomically null

BEGIN

r := Rational(2,3); -- r becomes 2/3

The null object is never equal to the other object. However, comparing a null object with any other object always results NULL. Also, if you assign an atomically null object to the other object, the other object becomes atomically null. Similarly, if you assign the non-value NULL to an object, the object becomes automatically null, as the illustration below shows:

DECLARE

r Rational;

BEGIN

r Rational := Rational(1,2); -- r becomes 1/2

r := NULL; -- r becomes atomically null

IF r IS NULL THEN ... -- condition yields TRUE

 

A good quality programming practice is to initialize an object in its declaration, as shown in the illustration shown below:

 

DECLARE

r Rational := Rational(2,3); -- r becomes 2/3

Posted Date: 10/6/2012 8:13:14 AM | Location : United States







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

Write discussion on Initializing objects in pl sql
Your posts are moderated
Related Questions
Fetching from a Cursor Variable The FETCH statement retrieve rows one at a time from the product set of a multi-row query. The syntax for the same is as shown: FETCH {curso

Data Types in SQL SQL's concept does not differ significantly from that defined in the theory book, apart from that business concerning NULL. However, the theory book equates

Parameter and Keyword Description: EXIT: An unconditional EXIT statement (i.e., one without a WHEN clause) exits the present loop instantly. The Execution resumes with th

GOTO Statement   The GOTO statement branches categorically to a block label or statement label. The label should be exclusive within its scope and should precede a PL/SQL bloc

TYPES OF EVOLUTION - Sequential evolution                  :                    Minor changes in the gene pool of a population from one generation to the next, with the resul

Project Description: I am looking to change FullCalendar to add/delete sql server data when events are removed or dropped from Calendar. Events should only be included by dra

Example of Using Aggregation on Nested Tables Example: How many students sat each exam WITH C_ER AS (SELECT CourseId, CAST (TABLE (SELECT DISTINCT StudentId, Mark FROM EXAM

Records Records are the items of the type RECORD. The Records have exclusively named fields that can store the data values of various types. And hence, a record treat associate

Transaction context As the figure shows, the major transaction shares its context with the nested transactions, but not with the autonomous transactions. Similarly, If one aut

Using a join on 2 tables, select all columns and 10 rows from the 2 tables without the use of a Cartesian product. Query: SELECT * FROM EMPLOYEE1 E JOIN STAFF S ON E.EMP_