As others have explained you only return a value if an exception occurred. If everything is OK, you don't return something. That can be fixed using the following code:
CREATE OR REPLACE FUNCTION loginSesion(pPassword VARCHAR2, pUser VARCHAR2)
RETURN NUMBER
IS
vPassword VARCHAR2(100);
vUsername VARCHAR2(100);
BEGIN
SELECT Person.Username, Person.Password INTO vUsername, vPassword
FROM Person
WHERE Person.Password = pPassword and Person.Username = pUser;
-- executed when a row was found
return 1;
EXCEPTION WHEN NO_DATA_FOUND THEN
-- executed when no row was found
RETURN 0;
END loginSesion;
/
Using an exception as a replacement for an IF condition is a bit of a code-smell (of course this is a bit subjective).
As you never use the values of the returned row, you can simplify the function to simply count the number of rows.
CREATE OR REPLACE FUNCTION loginSesion(pPassword VARCHAR2, pUser VARCHAR2)
RETURN NUMBER
IS
l_count integer;
BEGIN
SELECT count(*)
into l_count;
FROM Person
WHERE Person.Password = pPassword
and Person.Username = pUser;
if l_count = 0 then
return 0;
else
return 1;
end if;
END loginSesion;
/
If the calling code treats zero as "false" and anything greater then zero as "true", then you can remove the if and simply use return l_count;
The count() would also be necessary in case username is not unique (which I would find very strange). Because if there were two users with the same username, the select in the first solution would then throw a "select returned more then one row" exception.
trueorfalse...