First, I think, there had been an error shown when you tried to execute the code above. Like this:
ERROR: query has no destination for result data
HINT: If you want to discard the results of a SELECT, use PERFORM instead.
You need to store the result of the query into a variable and return it.
Second, your query returns an integer not a row so it *will* always return a result (even if it's null).
You need to define your SP so it returns a rowset (even it's a single row), in case you want to have an empty rowset when rows are not found (that's what I would expect

).