Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
I am ashamed to ask: Variables
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00393489
Message ID:
00394553
Vues:
10
>>>>Cindy,
>>>>
>>>> I guess, you're right. This is very important question, so keep it for DevCon, please.
>>>
>>>I've tested this with up to 21 items in the IN () statement without problem. However, in my test, the length of each item in the list matched the width of the field. Note that if the length of the field is wider than the items in the list and ANSI is set to ON the shorter items are padded with spaces. This will cause something like "CHI" in the list of items not to return a value for "CHICAGO" in the city field.
>>
>>
>> George,
>>
>> Try to test with 25 items. You will get an error message... I tested with the table, which has town (code) 4 character. Firstly I opened this table and wrote down couple of codes (guess, I could print it instead...), then I wrote the select statement in command window. I listed 13 items, but I got only 11 records. Anyway, I continued appending the list, and then I added 25th item, it gave me an error... I tested with VFP table.
>
>Nadya,
>
>You've just hit the limit is all. It isn't a bug. If you're willing to sacrifice compatibility with ANSI standard SQL, store the list items in an array, and use ASCAN() > 0 to achieve the same results.

My question is: where in Help can I find, that IN is limited by 24 codes? I know, it's true for INLIST(), but I didn't find a mention of it for IN, if it's the same in this context. I didn't understand your suggestion about ASCAN(), could you please be more specific.

I may tell you, that I'm currently do. I have an application, which allows our users to specify their criteria. It uses multiselect list and multiselect grids... I have to have where expression in a string after form unloads...
For multiselect lists (and grids) I have this code in btc_whereexp method:
********************************************************************
*  Description.......: BTCC_group.BTC_WherExp: method to obtain the search expression for this criterion
*  Calling Samples...:
*  Parameter List....: mapto_arg
*  Created by........: MDA
*  Modified by.......: Nadya Nosonovsky 01/24/2000 05:04:37 PM
********************************************************************
* 8/4/99: Adapted from preliminary logic for handling the Counties listbox.
* 8/5/99: support optional exclusion lists.
* 9/8/99: revised for support of query types.
* 9/9/99: introduce optional argument to this method, in order to handle cascading logic
*           as well as the final result criterion.
* 12/10/99 NN changed this method to use optimization
* This function returns a single piece of the search criteria, or empty string if nothing selected.

lparameters mapto_arg               && takes 1 optional argument
* mapto_arg:                         optional alias.fieldname mapping to use in resulting expression.
*                                        If omitted or empty, the mapping is determined by the array
*                                        property, btcmaparray, for the current query type.

local lcCrit, lcRetValue, lnSel, i, lnCodes, mapto

with this

     mapto=iif(empty(m.mapto_arg), .btcmaparray[thisform.btcqtmappingnum], m.mapto_arg)

     if empty(mapto) && empty for this Query Type
          lcRetValue=''
     endif

     lcCrit = .BTC_ItemList()          && get the list of selected items

     if empty(lcCrit)                    && no explicit selection was made
          lcRetValue=''                    && null criterion result
     endif


     if vartype(lcRetValue)='L' && Return value was not assigned yet
          if !empty(.CursorName) and pemstatus(this, 'btcselarray',5) && Need to insert records into cursor
               lnSel=select() && save current area
               select (.CursorName)
               zap && clear previous result

               lnCodes=alen(.btcselarray) && Number of selected items

               for i=1 to lnCodes
                    insert into (.CursorName) (code) ;
                         values (.btcselarray[i]) && Populate cursor
               next
               select (lnSel) && restore previous selection
          endif

        if empty(lnCodes) 
             lnCodes=occurs(',',lcCrit)+1 && Number of commas within crit
        endif

          do case
          case lnCodes=1 && only one value
               lcRetValue= mapto+iif(.ExcludeFlag,'<>','=')+lcCrit

          case lnCodes<=24 && INLIST function is limited by 24 codes

* return INLIST() criterion for field value in an enumerated list
               lcRetValue=  iif(.ExcludeFlag,'!','')+'INLIST(' + mapto + ',' + lcCrit + ')'

          otherwise

* Temproraly solution - breaks on the several INLISTs

               lcCrit=''
               lcRetValue=''

               for i=1 to lnCodes
                    lcCrit=lcCrit+'"'+.btcselarray[i]+'"'+iif(mod(i,24)=0 or i=lnCodes,'',',')
                    if mod(i,24)=0
                         if i>24
                              lcRetValue=lcRetValue+iif(.ExcludeFlag,' and !',' or ')+;
                                   'INLIST(' + mapto + ',' + lcCrit + ')'
                         else
                              lcRetValue=lcRetValue+iif(.ExcludeFlag,'!','')+;
                                   'INLIST(' + mapto + ',' + lcCrit + ')'
                         endif
                         lcCrit=''  && Start a new loop
                    endif
               next

               if !empty(lcCrit) && Remainder
                    lcRetValue=lcRetValue+iif(.ExcludeFlag,' and !',' or ')+;
                         'INLIST(' + mapto + ',' + lcCrit + ')'
               endif

               lcRetValue='('+lcRetValue+')' && Surrounded by ()
          endcase
     endif
endwith
return lcRetValue
It works fine...

Thanks in advance.
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform