The default value of a variable during declaration in PL SQL

What is the default value of the VARCHAR2 variable during declaration in PL / SQL? Can I check it for NULL after declaring a variable?

+4
source share
4 answers

Variables are initialized with NULL by default.

You can change this, 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 invalid:

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

The default value is NULL, you can use IS NULL or IS NOT NULL.

+2
source

tuinstoel is correct.

One addition: don't be fooled into trying "ls_my_variable = NULL", since comparing with NULL always returns FALSE. Always use "ls_my_variable IS NULL" or "IS NOT NULL".

0
source

And one more small addition: if you are dealing with BLOB (or CLOBS), "empty" is not the same as null. If you need to, refer to the Oracle Large Objects Guide.

0
source

All Articles