My apologies for the previous completely wrong mesage. I got mixed up
with operator meaning & precedence...
On Mon Oct 13, 2014 at 02:39:40PM +0100, Paul Sanderson wrote:
>
> My actual code is as folows
>
> (CASE visits.transition & 0xFFFFFF00 WHEN 0x00800000 THEN 'Blocked'
> ELSE '' END ||
But I can at least put some better light on your issue. SQLite returns
different results for your style of case/when construct:
CASE expr WHEN val THEN...
and the alternative which I find reads easier:
CASE WHEN truth_expr THEN...
Here's a demonstration:
WITH x
AS (
SELECT
0x01 AS a,
'0x01' AS txt
UNION ALL SELECT
0x10,
'0x10'
UNION ALL SELECT
0x01 | 0x10,
'0x01 | 0x10'
)
SELECT
x.txt,
CASE
WHEN x.a & 0x01
THEN 'A'
ELSE ''
END
|| ' ' ||
CASE
WHEN x.a & 0x10
THEN 'B'
ELSE ''
END AS result1,
CASE x.a & 0xff
WHEN 0x01
THEN 'A'
ELSE ''
END
|| ' ' ||
CASE x.a & 0xff
WHEN 0x10
THEN 'B'
ELSE ''
END AS result2
FROM
x
;
And the results:
txt result1 result2
---------- ---------- ----------
0x01 A A
0x10 B B
0x01 | 0x1 A B
--
MarkeLawrence
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users