oracle

Monday, 1 May 2017

PL/SQL: Constant

Constants are the user defined identifiers whose value remain unchanged during the execution of a program.
Syntax:
constant_name Constant datatype(size) := value;

Constant must be initialized during the declaration.

Example:
Declare
v_pi constant number:=3.14157;
begin
dbms_output.put_line(v_pi);
end;

Result:
3.14157

OR:

declare
v-pi constant number(7,6) not null default 3.14157;
begin
dbms_output.put_line(v_pi);

Result:
3.14157

This query prevent you to assigning null values to you constant.

No comments:

Post a Comment