CREATE OR REPLACE FUNCTION ip_num(ipaddress IN VARCHAR2) RETURN NUMBER AS
  ipnum NUMBER := 0;
  pos1  NUMBER := 0;
  pos2  NUMBER := 0;
BEGIN
  FOR i IN 1 .. 3 LOOP
    pos2  := to_number(instr(ipaddress, '.', 1, i));
    ipnum := ipnum + to_number(substr(ipaddress, pos1 + 1, pos2 - pos1 - 1)) *
             power(2, 8 * (4 - i));
    pos1  := pos2;
  END LOOP;
  ipnum := ipnum + to_number(substr(ipaddress, pos1 + 1));
  RETURN ipnum;
exception
  when others then
    return null;
END;
/

 

相关文章:

  • 2021-12-20
  • 2022-02-10
  • 2022-12-23
  • 2022-12-23
  • 2021-12-13
  • 2021-12-22
  • 2022-12-23
  • 2022-03-06
猜你喜欢
  • 2022-01-26
  • 2021-11-12
  • 2022-12-23
  • 2022-03-04
  • 2022-03-09
  • 2022-12-23
  • 2021-11-10
相关资源
相似解决方案