dbms_output cannot print boolean?

Shree Naath picture Shree Naath · Oct 19, 2016 · Viewed 24.6k times · Source

I am learning cursors and I cannot print the boolean value in the

dbms_output.put_line();

The code is

DECLARE
CURSOR c_employees_3i is
SELECT * FROM employees_3i;
row_count BOOLEAN;
BEGIN
OPEN c_employees_3i;
row_count := c_employees_3i%isopen; 
Dbms_Output.put_line(bool_to_text(row_count));
CLOSE c_employees_3i;
END;

I get this error

ORA-06550: line 8, column 22:
PLS-00201: identifier 'BOOL_TO_TEXT' must be declared
ORA-06550: line 8, column 1:
PL/SQL: Statement ignored

Please help me to rectify the error. Thanks

Answer

Frank Schmitt picture Frank Schmitt · Oct 19, 2016

The function bool_to_text does not exist (and AFAIK, Oracle never had such a function).

You can use diutil.bool_to_int to convert the Boolean to an Integer and print that:

begin
  dbms_output.put_line(sys.diutil.bool_to_int(true));
end;