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

Loop labels- iterative control, Loop Labels Like the PL/SQL blocks, loop...

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

Obtaining a natural join by specifying the common columns, Obtaining a natu...

Obtaining a natural join by specifying the common columns Synatax: SELECT * FROM IS_CALLED JOIN IS_ENROLLED_ON USING ( StudentId ) However, a named columns join doe

Parameter and keyword description - packages, Parameter and Keyword Descrip...

Parameter and Keyword Description: package_name: This construct identifies the package. AUTHID Clause: This determine whether all the packaged subprograms impleme

I want online credit application website, Project Description: We organi...

Project Description: We organize an online system called ACPAS we have created a project called EVO that can be use by our customers to integrate their web sites with the Acpas

Relational shema.., Find the account numbers of all customers whose balance...

Find the account numbers of all customers whose balance is more than 10,000 $

Use of count in sql, Use of COUNT in SQL It describes and discusses va...

Use of COUNT in SQL It describes and discusses various general methods of expressing constraints, eventually noting that support for "=" with relation operands is sufficient f

Using aliases-declarations in sql, Using Aliases The Select-list items f...

Using Aliases The Select-list items fetched from a cursor related with the %ROWTYPE should have simple names or, if they are expressions, should have aliases. In the example bel

Why use cursor variables, Why Use Cursor Variables ? Primarily, you use...

Why Use Cursor Variables ? Primarily, you use the cursor variables to pass the query result sets between the PL/SQL stored subprograms and different clients. Neither PL/SQL nor

Product-specific packages in pl/sql, Product-specific Packages The Ora...

Product-specific Packages The Oracle and different Oracle tools are supplied with the product-specific packages which help you to build the PL/SQL-based applications. For illu

Case sensitivity-naming conventions, Case Sensitivity Similar to all the...

Case Sensitivity Similar to all the identifiers, the variables, the names of constants, and parameters are not case sensitive. For illustration, PL/SQL considers the following n

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