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:
1 | SELECT BIN_TO_NUM(1) |
2 | FROM dual; |
Will return ‘1’
1 | SELECT BIN_TO_NUM(1,1) |
2 | FROM dual; |
Will return ‘3’
1 | SELECT BIN_TO_NUM(1,1,1) |
2 | FROM dual; |
Will return ‘7’
1 | SELECT BIN_TO_NUM(1,1,1,0) |
2 | FROM dual; |
Will return ‘14’