Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Cast() is evaluated for every record
Message
 
 
To
09/09/2004 05:12:09
General information
Forum:
Visual FoxPro
Category:
Visual FoxPro Beta
Miscellaneous
Thread ID:
00940524
Message ID:
00940736
Views:
18
Fabio,

Do not expect this behavior to be changed. I posted a bug report on this a couple of months ago and it is working as designed.

On the whole I'd say it's better to write the code using the new INSERT ... SELECT statements:
create cursor x1 ( c1 c(1) )
insert into x1 values ( 'a' )
insert into x1 values ( 'b' )

create cursor x2 ( c1 c(2) )
insert into x2 ;
   select * from x1
>On VFP the new CAST() function it will more become one of the functions used in SQL SELECT.
>
>Sin that the Engine does not recognize the specificity of this function and that the reexecute the CAST for every record, degrading the performances.
>
>A simple example, CAST a C(1) to a C(2):
>
>*********
>
>CLEAR
>SET TALK OFF
>
>CREATE CURSOR myCursor ( f1 C(1))
>
>FOR K=1 TO 100000
>INSERT INTO myCursor VALUES ('a')
>NEXT
>
>FOR K=1 TO 10000000
>NEXT
>
>T1=SECONDS()
>
>SELECT CAST(F1 AS C(2) NULL) F2 INTO CURSOR R1 FROM myCursor
>
>? 'TIME :',SECONDS()-T1
>LIST STRUCTURE
>
>T1=SECONDS()
>
>SELECT CAST(F1 AS C(2) NULL) F2 INTO CURSOR R2 FROM myCursor WHERE .F.;
>UNION ALL ;
>SELECT F1 FROM myCursor
>
>? 'TIME :',SECONDS()-T1
>LIST STRUCTURE
>
>
>The second it is twice more fast.
>
>Fabio
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform