Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Ascan exact in select-sql
Message
From
30/12/2004 05:59:09
 
 
General information
Forum:
Visual FoxPro
Category:
Troubleshooting
Environment versions
Visual FoxPro:
VFP 9
Miscellaneous
Thread ID:
00973127
Message ID:
00973217
Views:
12
>Hi,
>
>I think I found a bug and I wonder whether this bug is already known here.
>
>I'm using ascan() in a select-sql and have the flag set to 7 (1+2+4) in order to search for an exact match (and case-insensitive).
>To be more precise, for each record in a table a 4-char, yet alltrimmed, field is looked up in an array. Each element in the array is without spaces, but all elements are not empty. These are the critical field values in 4 records:
>"tem"
>"temt"
>"temc"
>"tema"
>Only "tem" is in the array. So, only that record should produce a 'found' result larger than 0. However, the other field values also produce that result! Imo, this is a bug.
>
>This bug is not happening if the ascan() is done as a separate command in a scan/endscan.
>
>Here is some simulation code:
local array laTmp[5]
>laTmp[1]='abc'
>laTmp[2]='cde'
>laTmp[3]='fgh'
>laTmp[4]='tem'
>laTmp[5]='ijk'
>
>create cursor c_tmp ( cString c(4) )
>insert into c_tmp values ( 'abc' )
>insert into c_tmp values ( 'ddd' )
>insert into c_tmp values ( 'eee' )
>insert into c_tmp values ( 'fff' )
>insert into c_tmp values ( 'tem' )
>insert into c_tmp values ( 'temt' )
>insert into c_tmp values ( 'temc' )
>insert into c_tmp values ( 'tema' )
>insert into c_tmp values ( 'xxx' )
>
>select ;
>	cString, ;
>	ascan( laTmp, rtrim( cString ), -1, -1, 0, 7 ) as cresult ;
>	from c_tmp ;
>	into cursor c_result readwrite
>
>select * from c_result into cursor c_tmp2
>
>insert into c_result values ( '', 0 )
>
>scan
>	c1 = cString
>	c2 = ascan( laTmp, rtrim( cString ), -1, -1, 0, 7 )
>	insert into c_result values ( c1, c2 )
>endscan
>
>select c_result
>browse last
It is a bug for me.

ASCAN can use SET ANSI ( with a description on the help ),
but only if the bit 2 it is 0.

Because ANSI OFF and EXACT OFF they are much differents,
all becomes little precise.

This code compare the four cases:
local array laTmp[5]
laTmp[1]='aBc'
laTmp[2]='cde'
laTmp[3]='tEmX'
laTmp[4]='tEm'
laTmp[5]=''

create cursor c_tmp ( pk I,cString c(4),ANSIOFF I,ANSION I, EXACTOFF I, EXACTON I )
insert into c_tmp values (1, 'abc ',0,0,0,0 )
insert into c_tmp values (2, 'Tem ',0,0,0,0  )
insert into c_tmp values (3, ''    ,0,0,0,0  )
insert into c_tmp values (4, 'xxx ',0,0,0,0  )

SET ANSI OFF

UPDATE c_tmp SET ANSIOFF=ascan( laTmp, rtrim( cString ), -1, -1, 0, 7 )

SET ANSI ON
UPDATE c_tmp SET ANSION=ascan( laTmp, rtrim( cString ), -1, -1, 0, 7 )

SET EXACT OFF
REPLACE ALL EXACTOFF WITH ascan( laTmp, rtrim( cString ), -1, -1, 0, 7 )

SET EXACT ON
REPLACE ALL EXACTON WITH ascan( laTmp, rtrim( cString ), -1, -1, 0, 7 )

LOCATE
browse LAST NOWAIT
Fabio
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform