ORACLE BIN_TO_NUM FUNCTION
bin_to_num converts binary value to Oracle Number.SYNTAX: bin_to_num(expr1,expr2,.....,exprn);
QUERY: Display equivalent of 110 in decimal
SQL> select bin_to_num(1,1,0) from dual;
BIN_TO_NUM(1,1,0)
-----------------
6
QUERY: Display equivalent of 1010 in decimal
SQL> select bin_to_num(1,0,1,0) from dual;
BIN_TO_NUM(1,0,1,0)
-------------------
10
QUERY: PL/SQL VARRAY has 5 binary numbers, converts into equivalent Number.
declare
type vab is varray(5) of number(1);
v_t vab:=vab(1,0,1,1,1);
n number;
begin
select bin_to_num(v_t(1),v_t(2),v_t(3),v_t(4),v_t(5)) into n from dual;
dbms_output.put_line(n);
end;
/
SQL> /
23
P/SQL procedure successfully completed.
No comments:
Post a Comment