Thanks a lot Dennis.It worked!
Sorry for asking one more question. I am new to SQLite so sorry for the 
question.
 
Can we convert these sql statement to function/store procedure so we can pass 
in the number and the return value back the character format.
For example : ConvertMAC(29672054730752  ) and the return value back : 
00:30:48:90:FC:1A
Thansk,
JP



----- Original Message ----
From: Dennis Cote <[EMAIL PROTECTED]>
To: General Discussion of SQLite Database <sqlite-users@sqlite.org>
Sent: Friday, September 12, 2008 11:12:32 AM
Subject: Re: [sqlite] Convert the MAC address from integer to characters.

Joanne Pham wrote:
> Sorry! the conversion is correct but it is in reverse order.
> The select statement return :
> 1A:FC:90:48:30:00
>  
> and I checked the MAC Address:
>  
>  00:30:48:90:fc:1a
> How to change it to correct order or may be the number 29672054730752  needs 
> to be reverse.
> Once again thanks for the help,

Simply rearrange the order of the byte pairs.

    select
        substr('0123456789ABCDEF', ((mac >> 4) & 15) + 1, 1) ||
        substr('0123456789ABCDEF', ((mac >> 0) & 15) + 1, 1) ||
        ':' ||
        substr('0123456789ABCDEF', ((mac >> 12) & 15) + 1, 1) ||
        substr('0123456789ABCDEF', ((mac >> 8) & 15) + 1, 1) ||
        ':' ||
        substr('0123456789ABCDEF', ((mac >> 20) & 15) + 1, 1) ||
        substr('0123456789ABCDEF', ((mac >> 16) & 15) + 1, 1) ||
        ':' ||
        substr('0123456789ABCDEF', ((mac >> 28) & 15) + 1, 1) ||
        substr('0123456789ABCDEF', ((mac >> 24) & 15) + 1, 1) ||
        ':' ||
        substr('0123456789ABCDEF', ((mac >> 36) & 15) + 1, 1) ||
        substr('0123456789ABCDEF', ((mac >> 32) & 15) + 1, 1) ||
        ':' ||
        substr('0123456789ABCDEF', ((mac >> 44) & 15) + 1, 1) ||
        substr('0123456789ABCDEF', ((mac >> 40) & 15) + 1, 1)
        as 'MAC Address'
    from t;

Dennis Cote
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users



      
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to