Constants and variables in pl sql, PL-SQL Programming

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.

Posted Date: 10/6/2012 9:10:04 AM | Location : United States







Related Discussions:- Constants and variables in pl sql, Assignment Help, Ask Question on Constants and variables in pl sql, Get Answer, Expert's Help, Constants and variables in pl sql Discussions

Write discussion on Constants and variables in pl sql
Your posts are moderated
Related Questions
Iteration Schemes The bounds of a loop range can be variables, literals, variables, or expressions but must compute to integers. Below are some of the examples. As you can see t

ROWID and UROWID Internally, every database table has a ROWID pseudo column that stores binary values known as rowids. Each rowid shows the storage address of a row. A physical

How Exceptions Propagate ? Whenever an exception is raised, and if the PL/SQL cannot find a handler for it in the present subprogram or block, the exception propagates. That is

Architecture The PL/SQL run-time system and compilation is a technology, not an independent product. Consider this technology as an engine that compiles and executes the PL/SQL

Referencing Records Unlike the elements in a collection, that are accessed using subscripts, the fields in a record are accessed by name. To reference an individual field, you

FORALL Statement The FORALL statements instruct the PL/SQL engine to bulk-bind the input collections before sending them to the SQL engine. Though the FORALL statement consists

Using research notes and Oracle documentation plan and execute an upgrade of an installation of Oracle 10g to Oracle 11g release 1. To do this you must show in screen shots and wri

The SQL ‘CREATE TABLE' scripts for all the tables you have implemented. Note that your tables must correspond exactly to the ERD you have provided in 1. above, or you will lose ma

Using LIMIT For nested tables, that have no maximum size, the LIMIT returns NULL. For varrays, the LIMIT returns the maximum number of elements that a varray can have (that yo

Advantages of Invoker Rights The Invoker-rights routines centralize the data retrieval. They are particularly helpful in applications which store data in various schemas. In su