Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Problem searching record...
Message
De
02/12/1999 10:41:05
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
02/12/1999 09:57:58
Jolene Dicks
Human Resources Development Canada
St. John's, Terre-Neuve, Canada
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00297876
Message ID:
00297907
Vues:
15
>Hi,
>
>Lets see if I can explain this clearly.
>
>I have a program that merges an update file with a data file. Basically, the program searches the data file by a unique key field and if it is found - it updates it; if it isn't found - it adds it. It uses the scatter/gather method to add or update the records.
>
>The unique key field's name is MTCKEY and is CHAR(26). This field is filled with a combination of 2 or 3 other field values and the length often varies as well as the spaces that might exist in the string. For instance, here are a few of the values for that field that is currently in my table.
>
>MTCKEY
>112807581M017273 119995701742
>112684618SKLOGR22919995268
>103536678A8020732919995268941
>103690368SKLOGR22919995261732
>105357933A726041 119995701742
>
>My program SCANS the update file and seeks the MTCKEY in the data file. It doesn't find it and therefore attempts to add it to the table. At that point I get a "Uniqueness of MTCKEY is violated" error, because it does actually exist in the data file but isn't found on the seek.
>
>CKEY="UPDFILE.MTCKEY"
>Select UpdFile
>Scan
> Scatter to ACjsNew Memvar Memo
> Select DataFile
> Seek(&CKey)
> If Found()
> Gather From ACjsNew Memvar Memo
> Else
> Append Blank
> Gather From ACjsNew Memvar Memo
> Endif
>Endscan
>
>I did some testing using a LOCATE instead and it still doesn't find it. I tried using this:
>
>LOCATE FOR ALLT(DATAFILE.MTCKEY) = ALLT(UPDFILE.MTCKEY)
>
>It works in some cases but not in all. You'de think that it would work.
>
>In any case, the program uses a seek for faster processing time and I don't want to use the LOCATE (even if I could get it to work). So I tried recreating the MTCKEY primary index to be:
>
>INDEX ON ALLT(MTCKEY) TAG MTCKEY
>
>Instead of :
>
>INDEX ON MTCKEY TAG MTCKEY
>
>That also doesn't work on the SEEK.
>
>I know that the problem isn't because it is at EOF(). I am at a loss here now and I am willing to take any suggestions. I assume the problem is related to the fact that there are spaces and inconsistant lengths of the values. But there must be a way around it. I assumed the ALLTRIM would also work, but it is causing me a little grief. Once again, any help would be greatly appreciated.
>
>Thanks,
>
>Jolene Dicks


CKEY="UPDFILE.MTCKEY"
lnPadSize=fsize("MTCKEY","DataFile")
set deleted off && deleted primary keys ?
Select UpdFile
Scan
  Scatter to ACjsNew Memvar Memo
  Select DataFile
  if Seek( padr(eval(CKey), lnPadSize), "MTCKEY", "DATAFILE" )
    Gather From ACjsNew Memvar Memo
    if deleted()
      && Recall or insert new ?
    endif
  Else
    insert into DataFile from memvar
  Endif
  select UpdFile
Endscan
Trimming is dangerous because keys like "A1" and "A12" would match if set exact is not on. padr() frees from thinking set exact.
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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform