Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Ascan exact in select-sql
Message
From
30/12/2004 03:37:28
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
General information
Forum:
Visual FoxPro
Category:
Troubleshooting
Environment versions
Visual FoxPro:
VFP 9
Miscellaneous
Thread ID:
00973127
Message ID:
00973197
Views:
13
>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
Peter,
I think it's not a bug (I mean at least result matches to documentation).
ascan() flags say it's 'set EXACT' override. SQL select OTOH use 'set ANSI' for exactness and not effected by 'set exact'. I haven't installed VFP9 but if this is returning the expected set then it's right IMHO:
Set Ansi On
select ;
	cString, ;
	ascan( laTmp, cString, -1, -1, 0, 7 ) as cresult ;
	from c_tmp
Set Ansi Off
PS: Unlike 'set exact' trailing spaces are not important.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform