Hello! On Sunday 15 March 2009 23:10:02 Roger Andersson wrote: > The SQL below might be out there but I didn't find it and since there might > be other that need to get 32-bit integer IP in a sqlite3 database to the > a.b.c.d format using SQL
There is extension for ipv4 http://mobigroup.ru/files/sqlite3.6.7/ipv4-ext.c This library will provide the ipv4 ISINNET, IP2INT, INT2IP, NETFROM, NETLENGTH, NETMASKLENGTH functions in SQL queries. The description of IP2INT function: IP2INT( ip ) IP2INT returns NULL if there is any kind of error, mainly : - strings are not valid IPV4 addresses or - number of bits is not a number or is out of range IP2INT returns integer number of IPV4 address otherwise SELECT IP2INT('192.168.1.1'); ==>3232235777 SELECT IP2INT('255.255.255.255'); ==>4294967295 SELECT IP2INT('0.0.0.0'); ==>0 The description of INT2IP function: INT2IP( int_number ) integer number may be a string ('3232235777' for example) or a number (3232235777 for example). Number 3232235777 is an integer number of the IPV4 address 192.168.1.1 IP2INT returns NULL if int_number is not an integer number. IP2INT returns IPV4 address otherwise. SELECT INT2IP(3232235777); SELECT INT2IP('3232235777'); ==>192.168.1.1 SELECT INT2IP(4294967295); SELECT INT2IP('4294967295'); ==>255.255.255.255 SELECT INT2IP(0); SELECT INT2IP('0'); ==>0.0.0.0 Best regards. _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users