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
Package STANDARD package named STANDARD defines the PL/SQL atmosphere. The package specification globally declares the exceptions, types, and subprograms that are available a

Assignment Statement: The assignment statement sets the present value of the variable, parameter, field, or element. The statement consists of an assignment target followed by

Project Description: I want to write some SQL statements. The things I need are between pages 5-7. The only problem is that i want it till tomorrow. Skills required is SQL

Cursor FOR Loops In most cases that need an explicit cursor, you can simplify the coding by using a cursor FOR loop rather of the OPEN, FETCH, and CLOSE statements. A cursor FO

Implicit Cursor is declared and used by the oracle environment internally. while the explicit cursor is declared and used by the external user. more over implicitly cursors are no

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

Multiple Assignment- SQL SQL supports multiple assignment to local variables and also applies multiple assignment semantics in SET clauses of UPDATE statements, but does not

Package STANDARD The package named STANDARD defines the PL/SQL atmosphere. The package specification globally declares the exceptions, types, and subprograms that are available

Tables within a Table - SQL Figure here is an exact copy of the one in the theory book and as before it is just an alternative way of representing some of the information con

Loop Labels Like the PL/SQL blocks, loops can also be labeled. The label, an undeclared identifier enclosed by double angle brackets, should appear at the beginning of the LOOP