Expression in assignment statement - pl sql, PL-SQL Programming

Assignment Help:

Expression:

This is a randomly complex combination of constants, variables, literals, operators, & function calls. The simplest expression consists of a single variable. If the assignment statement is executed, the expression is computed and the resulting value is stored in the assignment target. The value and target must have well-suited datatypes.

By default, unless the variable is initialized in its declaration, it is initialized to NULL every time a subprogram or block is entered. Therefore, never reference a variable before you assign it a value. You can't assign nulls to a variable defined as NOT NULL. If you attempt, the PL/SQL raises the predefined exception VALUE_ERROR. The values TRUE, FALSE, & NULL can also be assigned to a Boolean variable. If applied to an expression, the relational operators return a Boolean value. And hence, the assignment below is legal:

DECLARE

out_of_range BOOLEAN;

...

BEGIN

...

out_of_range := (salary < minimum) OR (salary > maximum);

As the later illustration shows, you can assign the value of an expression to an  explicit field in a record:

DECLARE

emp_rec emp%ROWTYPE;

BEGIN

...

emp_rec.sal := current_salary + increase;

Furthermore, you can assign values to all the fields in a record at once. The PL/SQL permits an aggregate assignment between the whole records if their declarations refer to similar cursor or table. For illustration, the assignment below is legal:

DECLARE

emp_rec1 emp%ROWTYPE;

emp_rec2 emp%ROWTYPE;

dept_rec dept%ROWTYPE;

BEGIN

...

emp_rec1 := emp_rec2;

The later assignment is illegal as you cannot use the assignment operator to assign the list of values to a record:

dept_rec := (60, 'PUBLICITY', 'LOS ANGELES');

Using the syntax below, you can assign the value of an expression to the specific element in a collection:

collection_name(index) := expression;

In the example below, you assign the uppercase value of the last_name to the third row in nested table ename_tab:

ename_tab(3) := UPPER(last_name);


Related Discussions:- Expression in assignment statement - pl sql

Data types in sql, Data Types in SQL SQL's concept does not differ sig...

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

Miller-urey''s experimental procedure, MILLER-UREY' S EXPERIMENTAL PROCEDU...

MILLER-UREY' S EXPERIMENTAL PROCEDURES - They recreated the probable conditions on the primitive earth in the laboratory. An atmosphere containing hydrogen, ammonia, me

What are decision support systems, (a) What are decision support systems, a...

(a) What are decision support systems, and what role do they play in the business environment? (b) Data warehousing is defined as "a subject-oriented, integrated, non-volatile c

I need data entry conversion project, Project Description: This is stage...

Project Description: This is stage 1 of a larger conversion project. We are converting a traditional Server/Client application written in Access 2007 into a web interface with S

Primary key, PRIMARY KEY: PRIMARY KEY  indicates that the table is sub...

PRIMARY KEY: PRIMARY KEY  indicates that the table is subject to a key constraint, in this case declaring that no two rows in the table assigned to ENROLMENT can ever have the

Projection and existential quantification - sql, Projection and Existential...

Projection and Existential Quantification - SQL Intuitively it might seem that projection in SQL is simply a matter of specifying the required columns in the SELECT clause, a

Positional notation, Positional Notation The first procedure call uses...

Positional Notation The first procedure call uses the positional notation. The PL/SQL compiler relates the first actual parameter, account, with the first proper parameter, ac

Introduction to oracle, Introduction Oracle 9i - it was made publ...

Introduction Oracle 9i - it was made public in the year 2001 with over 400 features, and graphics, it has merged the traditional business with modern internet application

Extension and and in sql, Extension and AND in SQL The theory book giv...

Extension and AND in SQL The theory book gives the following simple example of relational extension in Tutorial D: EXTEND IS_CALLED ADD ( FirstLetter ( Name ) AS Initial )

Declaring objects in pl/sql, Declaring Objects: You can use the object ...

Declaring Objects: You can use the object types wherever built-in types like CHAR or NUMBER can be used. In the block below, you can declare object r of type Rational. Then, yo

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