Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
UDF's second rate citizen in Rushmore ?
Message
From
08/09/2006 16:56:47
 
 
To
06/09/2006 04:51:40
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01151219
Message ID:
01152465
Views:
31
Hi Thomas,

This looks like a bug, VFP fails to match index expression because its byte code contains "possibly passed by ref" tag for each argument passed to UDF. If you enclose arguments in parenthesis in the index expression, the tag will not be included and existing index will be used.
CLEAR 

CREATE CURSOR newData (Field1 C(10), Field2 C(7))

APPEND BLANK
APPEND BLANK
APPEND BLANK
APPEND BLANK

index on Padr(myUdf1(Field1), 20) + Padr(myUdf2(Field2), 15) tag F_1_2_new

CREATE CURSOR oldData (Field1 C(10), Field2 C(7))

APPEND BLANK
APPEND BLANK
APPEND BLANK
APPEND BLANK

index on Padr(myUdf1(Field1), 20) + Padr(myUdf2(Field2), 15) tag F_1_2_Old

SYS(3054,12)

Select ;
    Nw.Field1, Ol.Field2 ;
    from newData Nw ;
    join oldData Ol ;
        on  Padr(myUdf1(ol.Field1), 20) + Padr(myUdf2(ol.Field2), 15) ;
          = Padr(myUdf1(nw.Field1), 20) + Padr(myUdf2(nw.Field2), 15) ;
INTO CURSOR res          

select newData 
delete TAG F_1_2_new
index on Padr(myUdf1((Field1)), 20) + Padr(myUdf2((Field2)), 15) tag F_1_2_new

select oldData 
delete TAG F_1_2_Old
index on Padr(myUdf1((Field1)), 20) + Padr(myUdf2((Field2)), 15) tag F_1_2_Old
?
Select ;
    Nw.Field1, Ol.Field2 ;
    from newData Nw ;
    join oldData Ol ;
        on  Padr(myUdf1(ol.Field1), 20) + Padr(myUdf2(ol.Field2), 15) ;
          = Padr(myUdf1(nw.Field1), 20) + Padr(myUdf2(nw.Field2), 15) ;
INTO CURSOR res          

SYS(3054,0)

FUNCTION myUdf1(val1)
	RETURN val1+val1
RETURN 

FUNCTION myUdf2(val2)
	RETURN val2+val2
RETURN 
Thanks,
Aleksey.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform