PL/SQL Exception

PL/SQL Exception

PL/SQL Interview Questions

PL/SQL Interview Questions and Answers


PL/SQL Constants

In PL/SQL Constants can be any numbers, boolean, strings or a null reference. Constants are particularly useful if there is a value which is used repeatedly throughout the program code. It is a user-defined literal value.

PL/SQL Drop Function Syntax

To define constants, use the following syntax:

Syntax

constant_name CONSTANT datatype := VALUE;      

Where:

constant_name: The constant name just like variable name.

VALUE: A value assigned to a constant when it is declared.

PL/SQL Constant example

The following PL/SQL show how to define constant i PL/SQL:

Example

DECLARE  
   -- constant declaration  
   PI constant number := 3.14;  
   -- other declarations  
   radius number(5,2);      
   ci number(7, 2);  
   area number (10, 2);  
BEGIN     
   area := PI * radius * radius; 
   ci := 2 * PI * radius;  
   -- output  
   DBMS_OUTPUT.PUT_LINE('Area of circle: ' || area);  
   DBMS_OUTPUT.PUT_LINE('Circumference : ' || ci);  
END;