Below is my code.
One variable is NOT having value. Another variable is having a value. In the below code, I want to print that the variables are
not same even in the case when var1
is not having any value. How can I do that?
CREATE OR REPLACE PACKAGE BODY mypackagebody IS
PROCEDURE comparenull() IS
l_var1 mytable.mycolumn1%TYPE;
l_var2 mytable.mycolumn2%TYPE;
BEGIN
BEGIN
SELECT var1
,var2
INTO l_var1
,l_var2
FROM mytable;
EXCEPTION
WHEN no_data_found THEN
var1 := NULL;
var2 := NULL;
END;
/* At this point var1 is NOT having any value and var2 is having a value.*/
/* The below if condition is returing false. But, I wanted to go inside the if condition and print that the var values are not same*/
IF var1 <> var2
THEN
dbms_ouput.put_line('var1 and var2 are not same');
END IF;
END comparenull;
END mypackagebody;