Skip to Main Content

Oracle Database Free

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

PL/SQL BOOLEAN to character string

user11763611Apr 12 2023

Hi!

I need a confirmation: TO_CHAR(boolean-column) works in SQL but not in PL/SQL?

I am missing something here?

BOOLEAN in PL/SQL has different semantics as BOOLEAN in pure SQL?

CREATE TABLE test1 ( b BOOLEAN );
INSERT INTO test1 VALUES ( NULL );
INSERT INTO test1 VALUES ( TRUE );
INSERT INTO test1 VALUES ( FALSE );
SELECT to_char(b) FROM test1;
DROP TABLE test1;

DECLARE
   x1 BOOLEAN := TRUE;
BEGIN
   dbms_output.put_line(' x1 = ' || to_char(x1) );
END;
/

Connected to:
Oracle Database 23c Free, Release 23.0.0.0.0 - Developer-Release
Version 23.2.0.0.0

Table created.

1 row created.

1 row created.

1 row created.

TO_CHAR(B)
---------------
TRUE
FALSE

Table dropped.
   dbms_output.put_line(' x1 = ' || to_char(x1) );
                                    *
ERROR at line 4:
ORA-06550: line 4, column 38:
PLS-00306: wrong number or types of arguments in call to 'TO_CHAR'
ORA-06550: line 4, column 5:
PL/SQL: Statement ignored
Comments
Post Details
Added on Apr 12 2023
8 comments
2,851 views