日期:2014-05-16 浏览次数:20506 次
create or replace FUNCTION f_ipToLong(ip in varchar2) return number is p1 number; p2 number; p3 number; begin p1 := instr(ip, '.', 1, 1); p2 := instr(ip, '.', 1, 2); p3 := instr(ip, '.', 1, 3); return to_number(substr(ip, 1, p1-1))*256*256*256 + to_number(substr(ip, p1+1, p2-p1-1))*256*256 + to_number(substr(ip, p2+1, p3-p2-1))*256 + to_number(substr(ip, p3+1)); end;
create or replace FUNCTION f_longToIp(ip in number) return varchar2 is begin return floor(ip/65536/256) || '.' || mod(floor(ip/65536), 256) || '.' || mod(floor(ip/256), 256) || '.' || mod(ip, 256); end;?
select * from ipLib where (select f_iptolong('8.8.8.8') from dual) between ip_1 and ip_2;?
?