Oracle bin_to_num 函数用于将二进制位转换成十进制的数,KingbaseES 从 V8R6C4版本开始支持该函数。具体使用方法如下。
1、传入参数
test=# \df bin_to_num List of functions Schema | Name | Result data type | Argument data types | Type --------+------------+------------------+---------------------+------ sys | bin_to_num | numeric | VARIADIC "any" | func
bin_to_num 传入的参数必须是 0 或 1,参数个数不限。
2、使用例子
test=# select bin_to_num(1,1,1,1,1) from dual; bin_to_num ------------ 31 (1 row) test=# select bin_to_num(1,1,1) from dual; bin_to_num ------------ 7 (1 row) test=# select bin_to_num(1,1,1,1,1,0,0,1,1) from dual; bin_to_num ------------ 499 (1 row)