I have this code that is part of a stored procedure:
SET @_Value = 0
SET @_Cont = 1;
IF(@_FlagControl = 1)
BEGIN
SELECT @_Value = SUM(Value)
FROM Person P
INNER JOIN Order O on O.CodPerson = P.CodOrder
WHERE P.CodPerson = @_CodP
AND P.CodImp <> 3
AND P.FlagSituation = 1
AND @_CodMainPerson = P.CodPerson
IF(@_Value IS NULL)
PRINT 'NULL'
ELSE
PRINT @_Value
END
If I run just this SELECT
inside the "IF", it returns '0.90'. But when I run this entire query inside a procedure, it is printing NULL.
I don't have idea what is going on.