On Sun, 15 Mar 2009 21:10:02 +0100, "Roger Andersson"
<r...@telia.com> wrote:

>Hi!
>
> 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
>
> I did get started from
> http://acidlab.sourceforge.net/acid_faq.html#faq_e1
> and for me what's below does the trick in sqlite3 :-)
>
> SELECT
>  CAST((intIP & 4278190080) >> 24 AS text)||'.'||
>  CAST((intIP & 16711680) >> 16 AS text)||'.'||
>  CAST((intIP & 65280) >> 8 AS text)||'.'||
>  CAST((intIP & 255) AS text) AS strIP
> FROM IP_table;

Cute code, thanks.
The implementation of BitAnd and ShiftRight in the 
SQLite VM (~line 10176 in the amalgamated sqlite.c)
is very straightforward and should be pretty fast.

>Cheers
>Roger
-- 
  (  Kees Nuyt
  )
c[_]
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to