Ticker

6/recent/ticker-posts

Constants in PL/SQL : Declaration, Syntax

 

Constants in PL/SQL

A constant holds a value that once declared, does not change in the prouram. Declaring a constant is similar to declaring a variable—eve-lit that you have to add he keyword 'constant' and immediately assign a value to it. Thereafter, no further assignments to the constant are possible. This constant can be used anywhere in the code. 

For example:

C_Max CONSTANT NUMBER: = 500; 

C_Exp CONSTANT VARCHAR2: = `MIN5' 

Minval CONSTANT INTEGER(2): = 22; 

Using Logical Comparisons in PL/SQL 

PL/SQL supports the comparison between variables and constants in SQL and PL/SQL statements. These comparisons, often called Boolean expressions, generally consist of simple expressions separated by relational operators (<, >, =, < >, >=, <= that can be connected by logical operators (AND, OR, NOT). A Boolean expression will always evaluate to TRUE, FALSE or NULL. 

For example, (A <7 b >=-: a 2*a = b) ---> Numeric comparisons 

(Namel > name2, namel = 'Jones', Product_type != 'COMPUTER')-> Character comparisons 

(birthday < '05-Jul-59', hiredate <=sysdate) ---> date comparisons