Check if a variable is null in plsql

user223541 picture user223541 · Dec 31, 2009 · Viewed 134.3k times · Source

I want to check if a variable is null. If it is null, then I want to set a value to that variable:

//data type of var is  number 
if Var = null then
  var :=5;
endif

But I am geting error in it. How can I check if a variable is null?

I am using oracle data type

Answer

Priyank picture Priyank · Dec 31, 2009
if var is NULL then
  var :=5;
end if;