PL/SQL - SPLessons
SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

PL/SQL Constant

PL/SQL Constant

shape Description

PLSQL Constant is used as a part of PL/SQL block. And, it is a client characterized programming value. These constants are qualities that once assigned cannot be renamed throughout the program. Instead of genuine qualities, one can assign a constant value. The declaration of a PLSQL Constant determines its data type, values, storage allocated and name. NOT NULL constraints can be imposed in the declaration of these variables.

shape Syntax

Constant_name CONSTANT datatype :=VALUE; Constant_name => Name of the constant. Constant => Is a reserved word. Value => The value that assigned to a constant.

shape Examples

The following example illustrates the constant PL/SQL execution. [c]SQL> DECLARE 2 -- constant declaration 3 pi constant number :=3.14159; 4 -- other declarations 5 radius number(5,2); 6 dia number(5,2); 7 circumference number(7,2); 8 area number(10,2); 9 BEGIN 10 -- processing 11 radius :=9.5; 12 dia:=radius*2; 13 circumference:=2.0*radius; 14 15 area:=pi*radius*radius; 16 --output 17 dbms_output.put_line(Radius:'||radius); 18 dbms_output.put_line('Diameter:'||dia); 19 dbms_output.put_line('circumference:'||circumference); 20 dbms_output.put_line('Area:'||area); 21 END; 22 / Radius:9.5 Diameter:19 Circumference:59.69 Area:283.53 PL/SQL procedure successfully completed.[/c] In the above example, the execution of PLSQL Constant block is defined for finding the value of radius, diameter, circumference and area.

Semantics declarations

shape Description

Semantic declarations contain different declaration syntax that is used in PL/SQL program execution. The following are the PL/SQL semantics constraints:

NOT NULL

The NOT NULL constraints are allocated to constant or scalar variables. These NOT NULL constraints avert allocating a null quality value to the item. One can obtain this constraint either explicitly or implicitly.

Constant

Constants are the names that are proclaimed in semantics PL/SQL block.

Expressions

Expressions must have a data type that is perfect with another datatype. When constant_declaration is liberated, the estimations of explanations is allocated to the constant.

Datatypes

Variables can be declared with an initial value inside the datatypes.

Summary

shape Key Points

  • PLSQL Constant - It is a client characterized programming value.
  • Semantics declarations - Contains different declaration syntax that are used in the execution of PL/SQL programs.
  • NOT Null - Assigns constant or scaler variables.
  • Constant - Name that is proclaimed in the semantic PL/SQL block.
  • Expressions - Connects from one datatype to another datatype.
  • Datatypes - Declared with an initial value inside the datatypes.