Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Boolean Challenge Anyone?
Message
 
 
À
29/12/2007 17:37:07
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 7 SP1
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
Visual FoxPro
Divers
Thread ID:
01278379
Message ID:
01278388
Vues:
17
Hi Ray,

You'll have to creaet a supporting table that converts each bit into corresponding time interval. The code below shows how to do that for one field
* Creating test data
CREATE CURSOR sch (pid int, s1 int, s2 int, rid int autoinc)
INSERT INTO sch (pid, s1, s2) VALUES (1, 1+4+32+32768, 1)

CREATE CURSOR s1_15 ( bit int, sh char(5))
ltDt = DATETIME(2000,1,1,0,0,0)
FOR i=1 TO 31
	INSERT INTO s1_15 VALUES (2^(i-1), SUBSTR(TTOC(ltDt + (i-1) * 15*60,3), 12,5))
ENDFOR

* Query
SELECT * FROM sch ;
	JOIN s1_15 ON BITAND(sch.s1, s1_15.bit) > 0
>I have an application that tracks a person’s scheduled daily activities in two integer fields by setting a single bit for each 15-minute block of time. With 32 bits in each field, that gives me 16 hours of coverage for a day and I can safely ignore the back side of the clock, so that is sufficient.
>
>I now have to create an availability chart with a single record for each individual that shows all scheduled 15-minute blocks for a day. Since each person may have more than one record for a day, showing different scheduled periods, that involves a BITOR() of each of the relevant integer fields in those records to combine all scheduled blocks into a single record with the same pair of integer fields.
>
>Can any of you clever people come up with an elegant way to accomplish this—inside a SQL SELECT—or otherwise? Something better than a brute-force SCAN FOR or DO WHILE loop for each individual? I’ve wracked my brain for longer than I want to admit without coming up with anything approaching “elegant.”
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform