BIN_TO_NUM Function in Oracle SQL – PLSQL

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:

[sourcecode language=”sql”]
SELECT BIN_TO_NUM(1)
FROM dual;
[/sourcecode]

Will return ‘1’

[sourcecode language=”sql”]
SELECT BIN_TO_NUM(1,1)
FROM dual;
[/sourcecode]

Will return ‘3’

[sourcecode language=”sql”]
SELECT BIN_TO_NUM(1,1,1)
FROM dual;
[/sourcecode]

Will return ‘7’

[sourcecode language=”sql”]
SELECT BIN_TO_NUM(1,1,1,0)
FROM dual;
[/sourcecode]

Will return ‘14’


Leave a Reply

Your email address will not be published. Required fields are marked *