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:
00940696
Views:
15
Interesting use of CAST function, and thanks for comparison. This is great to know for changing the width of data, but the UNION select technique "fails", for example, when F1 is numeric - N(x,0) - and you want to cast as integer. By fails, I mean the resulting cursor comes back with a numeric field instead of integer. Primarily, CAST() was added to convert between data types.

>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
Mark McCasland
Midlothian, TX USA
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform