The BIN_TO_NUM Function in Oracle SQL / PLSQL is used to convert the bit vector to a number type.
Syntax for the using the BIN_TO_NUM Function in Oracle SQL / PLSQL is:
SELECT BIT_TO_NUM(expression1,expression2, . .expressionN)
FROM table_name;
expression1, expression2, . ., expressionN must be either 0 or 1 and they represent bits in a bit vector.
Examples:
Using BIN_TO_NUM Function in Oracle SQL / PLSQL SELECT statement:
SELECT BIN_TO_NUM(1) FROM dual;
Will return ‘1’
SELECT BIN_TO_NUM(1,1) FROM dual;
Will return ‘3’
SELECT BIN_TO_NUM(1,1,1) FROM dual;
Will return ‘7’
SELECT BIN_TO_NUM(1,1,1,0) FROM dual;
Will return ‘14’