Message
 
To
28/07/2003 12:22:51
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00813951
Message ID:
00814235
Views:
11
PMBI, assuming that you mean a contiguous block of 1000 ids that have not been used, then maybe this will help
CREATE CURSOR idpool (id i, idused L)
LOCAL i,cntused

FOR i = 1 TO 20000
	INSERT INTO idpool (id, idused) VALUES(i,MOD(i,RAND()*100)=0)
ENDFOR

COUNT FOR idused TO cntused

?cntused
LOCATE FOR idused
lnblocktop=RECNO()
lnstartid=id
DO WHILE .t.
	CONTINUE
	IF RECNO()> lnblocktop+999
		?'Found Block of 1000 unused Ids starting with id #'+STR(lnstartid)
		EXIT
	ELSE
		lnblocktop=RECNO()
		lnstartid=id
	ENDIF
	IF EOF()
		?"No block of 1000 Unused Ids found."
		EXIT
	ENDIF
ENDDO
Tom

Life happens, don't blink.
Previous
Reply
Map
View