3

Possible Duplicate:
How to use BOOLEAN type in SELECT statement

I have tried running SQLPLUS on functions I've written which return the BOOLEAN data type. Is there any way to run these BOOLEAN functions from SQLPLUS? It seems that the BOOLEAN data type is not accessible at all from SQLPLUS.

EDIT: I should have mentioned I was only working with SQLPLUS bind variables, not the standard DECLARE... PLSQL variables.

Community
  • 1
  • 1
T. Webster
  • 9,605
  • 6
  • 67
  • 94

1 Answers1

4

The BOOLEAN data type is defined in PL/SQL but not SQL. If you are writing PL/SQL, you can happily use BOOLEAN types from within SQL*Plus or any other tool.

DECLARE
  l_some_bool BOOLEAN := true;
BEGIN
  IF( l_some_bool )
  THEN
    dbms_output.put_line( 'true' );
  END IF;
END;

If you are writing SQL, however, you cannot use BOOLEAN types regardless of the tool you are using because the SQL language doesn't recognize the type. A function that returns a BOOLEAN, for example, cannot be called in a SQL statement.

Justin Cave
  • 227,342
  • 24
  • 367
  • 384
  • that should have been obvious. I should have mentioned I was working with SQLPLUS bind variables. – T. Webster Aug 07 '12 at 15:07
  • The question is if you can declare a variable of type BOOLEAN in SQL*Plus, not PL/SQL. The accepted answer does not address the question. – RKA Apr 25 '20 at 18:49