On 2014/10/13 15:39, Paul Sanderson wrote:
Thanks all

Clemens - I went initially for your solution as it fitsbetter with some
other work i have done

My actual code is as folows

   (CASE visits.transition & 0xFFFFFF00  WHEN 0x00800000 THEN 'Blocked'
     ELSE '' END ||
    CASE visits.transition & 0xFFFFFF00  WHEN 0x01000000 THEN
'Forward_Back'      ELSE '' END ||
    CASE visits.transition & 0xFFFFFF00  WHEN 0x02000000 THEN
'From_Address_Bar' ELSE '' END ||
    CASE visits.transition & 0xFFFFFF00  WHEN 0x04000000 THEN 'Home_Page'
     ELSE '' END ||
    CASE visits.transition & 0xFFFFFF00  WHEN 0x08000000 THEN 'From_API'
     ELSE '' END ||
    CASE visits.transition & 0xFFFFFF00  WHEN 0x10000000 THEN 'Chain_Start'
     ELSE '' END ||
    CASE visits.transition & 0xFFFFFF00  WHEN 0x20000000 THEN 'Chain_end'
     ELSE '' END ||
    CASE visits.transition & 0xFFFFFF00  WHEN 0x40000000 THEN
'Client_Redirect'  ELSE '' END ||
    CASE visits.transition & 0xFFFFFF00  WHEN 0x80000000 THEN
'Server_Redirect'  ELSE '' END ||
    CASE visits.transition & 0xFFFFFF00  WHEN 0xC0000000 THEN
'Is_Redirect_Mask' ELSE '' END )
   AS Qualifiers

The query is on a visits table from a google chrome history database. The
query seems to work OK if a single bit is set, but fails (a blank string is
returned) when multiple bits are set. Any ideas why?

Rookie mistake :)

You are basically bitwise AND-ing 2 values together, such as (visits.transition & 0xFFFFFF00) and then checking the result against a single bit... this will never work unless the transition value has only a single bit set, I think you meant to AND the mask with the transition value and then check if the result is non-zero?

This works perfectly for me:

  (CASE WHEN (visits.transition & 0x00800000)>0 THEN 'Blocked'
    ELSE '' END ||... etc. etc.

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

Reply via email to