Den 2016-10-17 kl. 16:40, skrev R Smith:
Luckily all data needed is in the table, and Igor's method will work
just dandy in your case. Why not store the flags in full rather than
per line though? You can easily manipulate the values by using
standard bit-masking and boolean bit-wise functions in SQL.
Ex1. Set bit 3 of field fbit for unit 1: UPDATE Tabel1 SET fbit
= ((1 << 3) || fbit) WHERE unit = 1;
Ex2. Read bit 3 of field fbit for unit 1: SELECT (fbit && (1 << 3))
> 0 FROM Tabel1 WHERE unit = 1;
This way you can just read the fbit from a record in stead of having
to go through all the grouping and aggregating to pivot it.
I can't manipulate the source data, so my idea is to create a mirror
table with the bits already stored in "bytes". I intend to use the
SELECT in a trigger on the source data table which synchronize the bits
into bytes in the mirror table so I don't need to handle individual bits.
sqlite-users mailing list