oracle ip地址转换为整数 整数转换为ip代码 | 您所在的位置:网站首页 › ip地址转换为数字的函数 › oracle ip地址转换为整数 整数转换为ip代码 |
2:ip地址转换为整数: 在oracle中创建如下函数即可:
create or replace function striptoint( dottedQuad IN VARCHAR2) return number is Result NUMBER; begin Result:= (substr(dottedQuad , 1, (instr(dottedQuad , '.', 1, 1 ) - 1)) * 256 * 256 * 256 ) + (substr(dottedQuad , instr(dottedQuad , '.', 1, 1 ) + 1, instr(dottedQuad , '.', 1, 2 ) - instr(dottedQuad , '.', 1, 1 ) - 1) * 256 * 256 ) + (substr(dottedQuad , instr(dottedQuad , '.', 1, 2 ) + 1, instr(dottedQuad , '.', 1, 3 ) - instr(dottedQuad , '.', 1, 2 ) - 1) * 256 ) + (substr(dottedQuad , instr(dottedQuad , '.', 1, 3 ) + 1) ) ; return(Result ); end iptoint ;
使用: select striptoint('10.10.10.10') from dual 结果: 168430090 |
CopyRight 2018-2019 实验室设备网 版权所有 |