default value of a variable at the time of declaration in PL SQL

oracle, plsql, sql

Solution

Variables are default initialized with NULL.

You can change that, for example:

create procedure show1
as
  l_start varchar2(10) := 'Hello';
begin
  if l_start is not null then 
    ....
  end if;
end;
/

You can also declare variables as not nullable:

create procedure show2
as
  l_start varchar2(10) not null := 'Hello';
begin
  null;
end;
/

Problem

What is the default value of a variable `VARCHAR2` at the time of declaration in PL/SQL? Can I check it against `NULL` once after I declare a variable?

Original source