SQL> set serveroutput on
SQL> declare v boolean;
2 begin
3 v := true;
4 dbms_output.put_line( 'True retorna '||sys.diutil.bool_to_int(v) );
5 v := false;
6 dbms_output.put_line( 'False retorna '||sys.diutil.bool_to_int(v) );
7 end;
8 /
True retorna 1
False retorna 0
PL/SQL procedure successfully completed.
SQL>
Funciona também para comparações:
SQL> begin
2 dbms_output.put_line( sys.diutil.bool_to_int(1=1) );
3 dbms_output.put_line( sys.diutil.bool_to_int(1=2) );
4 end;
5 /
1
0
PL/SQL procedure successfully completed.
SQL>
SQL> select sys.diutil.bool_to_int(1=1) from dual;
select sys.diutil.bool_to_int(1=1) from dual
*
ERROR at line 1:
ORA-00907: missing right parenthesis
SQL> select sys.diutil.bool_to_int(true) from dual;
select sys.diutil.bool_to_int(true) from dual
*
ERROR at line 1:
ORA-00904: invalid column name