Constants and variables in pl sql, PL-SQL Programming

Assignment Help:

Constants and Variables:

 You can declare the constants and variables in the declarative section of any PL/SQL subprogram, block, or package. The Declarations allot the storage space for a value that specify its datatype, and name the storage space location so that you can reference it. The Declarations can also assign an initial value and enforce the NOT NULL constraint.

1070_constant variable.png

Keyword and Parameter Description:

constant_name:

These identify the program constant.

CONSTANT:

These keywords indicate the declaration of a constant. You should initialize a constant in its declaration. The value of a constant cannot be changed if once it is initialized.

record_name.field_name:

These identify the field in a user-defined or %ROWTYPE record formerly declared within the present scope.

scalar_type_name:

These identify a predefined scalar datatype like the BOOLEAN, NUMBER, or VARCHAR2.

db_table_name.column_name:

These identify a database table and column that should be available when the declaration is elaborated.

variable_name:

These identify the program variable.

collection_name:

These identify the nested table, index-by table, or varray earlier declared within the present scope.

cursor_name:

These identify an explicit cursor formerly declared within the present scope.

cursor_variable_name:

These identify a PL/SQL cursor variable formerly declared within the present scope.

object_name:

These identify an object (or instance of the object type) formerly declared within the present scope.

record_name:

These identify a user-defined record formerly declared within the present scope.

db_table_name:

These identify a database table (or view) that should be available when the declaration is elaborated.

%ROWTYPE:

This attribute gives a record type that presents a row in the database table or a row fetched from a formerly declared cursor. The Fields in the record and corresponding columns in the row have similar names and datatypes.

%TYPE:

This attribute gives the datatype of a formerly declared collection, field, cursor variable, object, record, database column, or variable.

NOT NULL:

These constraints prevent the assigning of the nulls to a variable or constant. At run time, trying to assign the null to a variable defined as NOT NULL raises the predefined exception VALUE_ERROR. The constraint NOT NULL should be followed by an initialization clause.

Expression:

This is a randomly complex combination of the variables, literals, constants, operators, and function calls. The easiest expression consists of a single variable. If the declaration is elaborated, the value of the expression is assigned to the constant or variable. The value and the constant or variable should have compatible datatypes.


Related Discussions:- Constants and variables in pl sql

Multiple assignment - sql, Multiple Assignment- SQL SQL supports mult...

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

Type versus representation confusion in sql, Type versus Representation Con...

Type versus Representation Confusion in SQL This describes how a value might have two or more distinct representations. For example, user-defined type POINT might have a decla

Enforce security in the database system, Question: (a) In the context o...

Question: (a) In the context of database security explain how the following database features help to enforce security in the database system: (i) Authorisation (ii) Access

Create a procedure to tax calculation task, Complete the following steps to...

Complete the following steps to create a procedure to calculate the tax on an order. The BB_TAX table contains the states that require taxes to be submitted for Internet sales. If

Iterative control: loop statement, Iterative Control: LOOP  Statements T...

Iterative Control: LOOP  Statements The LOOP statement executes a series of statements multiple times. There are 3 forms of LOOP statements: LOOP, WHILE-LOOP, & FOR-LOOP. LOOP

Structure of an object type in pl/sql, Structure of an Object Type: Si...

Structure of an Object Type: Similar to package, an object type has 2 parts: the specification and the body. The specification is the interface to your applications; it declar

Effects of null for union - sql, Effects of NULL for union - SQL The ...

Effects of NULL for union - SQL The treatment of NULL in invocations of EXCEPT is as for UNION. This is different from its treatment in those of NOT IN and quantified compari

Difference between 9i & 10g, Difference between 9i & 10G When Oracle r...

Difference between 9i & 10G When Oracle releases any new databases then it are having some discrepancy with them. But 10G is having much difference than oracle 9i has. Oracle

Example of shorthand for a row constraint - sql, Example of Shorthand for a...

Example of Shorthand for a row constraint Example: Shorthand for a row constraint ALTER TABLE EXAM_MARK ADD CONSTRAINT Mark_in_range CHECK (Mark BETWEEN 0 AND 100);

How to use the explain plan for statement, Using the student and faculty ta...

Using the student and faculty tables create a select query that outputs all students for a specific advisor. Generate the execution plan, select out the explain plan . Create an

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