I've created this afternoon this PL/SQL function :
CREATE OR REPLACE FUNCTION CHECK_CIN_CLOSED_LINE
(combination IN VARCHAR2 DEFAULT '')
RETURN BOOLEAN
IS
solution BOOLEAN := false;
cursor c1 is
SELECT (1)
FROM RS2QTCIN cin, RS2QTGIN gin
WHERE cin.group_id = gin.id
AND cin.cin_value = combination
and cin.date_end is not null;
my_c1 c1%rowtype;
BEGIN
open c1;
FETCH c1 INTO my_c1;
IF c1%NOTFOUND THEN
IF c1%ROWCOUNT != 0 THEN
solution := true;
END IF;
END IF;
close c1;
RETURN solution;
EXCEPTION
WHEN OTHERS THEN
raise_application_error(-20001,'An error was encountered - '||SQLCODE||' -ERROR- '||SQLERRM);
END;
The problem comes when testing in with a simple call. For example :
select check_cin_closed_line('1PW2+UB07') from dual;
select CHECK_CIN_CLOSED_LINE('') from dual;
Both test calls return an error of invalid datatype (ORA-00902 - 00902. 00000 - "invalid datatype") I dont't understand the reason of this error, the input parameter is varchar2 variable and the input value is a varchar value.
SELECT (1)
..? – Barbaros ÖzhanSELECT COUNT(1)
might be preferred. Btw, a boolean value cannot be invoked within a SQL Statement, but might be assigned wthin a from PL/SQL Block as @Patrick Bacon stated. – Barbaros Özhan