Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Why?
Message
De
16/06/2009 07:02:46
 
 
À
16/06/2009 06:38:53
Lutz Scheffler
Lutz Scheffler Software Ingenieurbüro
Dresden, Allemagne
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
Re: Why?
Divers
Thread ID:
01406283
Message ID:
01406290
Vues:
79
Agnes,

The question was why there were different results

I know that a FOR does not order if there is no order set

But for the second example you need an order set for the 'scan rest while' to work

On a sidenote - an index set + seek() + Scan rest while() is faster than a scan for in larger tables

Are we in agreement ?

See this
	create cursor pp ;
	(	inv	c(6), ;
		PK c(4) ;
	)
	insert into pp values ('000033', '0001')
	insert into pp values ('000033', '0002')
	
	insert into pp values ('000099', '0001')
	insert into pp values ('000099', '0002')
	insert into pp values ('000099', '0045')
	insert into pp values ('000099', '0046')
	
	insert into pp values ('000033', '0045')
	insert into pp values ('000033', '0046')
	
	index on inv tag inv
	
	set order to
	
	&& (1) output
	&& 0001
	&& 0002
	
	mkey='000033'
	seek mkey order inv
	
	scan while inv=mkey
	  ? '(1) ', PK
	endscan
	
	
	&& (2) output
	&& 0001
	&& 0002
	&& 0045
	&& 0046
	set order to inv
	mkey='000033'
	seek mkey order inv
	
	scan while inv=mkey
	   ? '(2) ', PK
	endscan

>Hi Gregory,
>
>I do not think that the problem is the order. It will cure the problem to the first, yes.
>
>But DISPLAY .. FOR .. will not order the result, it will display the records in the order they are stored.
>So the ascending list
>>>0001
>>>0002
>>>0045
>>>0046
>comes out of coincedence, not of a preset order.
>
>He need a SCAN FOR ... instead of SCAN WHILE ..., and he can delete the SEEK.
>
>Agnes
>
>>In the second example you have to set the order to inv
>>
>>
>> use sales in 0 alias sales order inv
>>
>>>select sales
>>>mkey='003333'
>>
>> seek mkey
>>
>>>scan while inv=mkey
>>>    disp PK
>>>endscan
>>>use in sales
>>
>>
>>
>>
>>>I wonder why these two codes show difference results:
>>>
>>>
>>>use sales in 0 alias sales
>>>select sales
>>>mkey='003333'
>>>disp PK for inv=mkey
>>>use in sales
>>>
>>>
>>>result:
>>>--------
>>>0001
>>>0002
>>>0045
>>>0046
>>>
>>>
>>>use sales in 0 alias sales
>>>select sales
>>>mkey='003333'
>>>seek mkey order inv
>>>scan while inv=mkey
>>>    disp PK
>>>endscan
>>>use in sales
>>>
>>>
>>>result:
>>>-------
>>>0001
>>>0002
>>>
>>>
>>>thanks for the help
Gregory
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform