Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Duplicate primary key
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01423254
Message ID:
01423269
Vues:
37
Naomi,
many thanks for the reply, i'll try these tomorrow
~M


>Mark,
>
>I always use SEEK function instead or in your case you can also use INDEXSEEK.
>
>Also, if we're talking about VFP 9 SP2 we can do instead
>
>insert into NWC select * from (mFileName) Ap LEFT JOIN NWC on Ap.CMA_CalNum = NWC.CMA_CalNum where NWC.CMA_CalNum is NULL
>
>and therefore we would not need any extra code at all.
>
>In any case, I made few minor changes inside your code as well.
>
>>Naomi,
>>thanks for the reply. I did leave a bit out. when i read on the file names into the array i then loop through the array and use the file to be imported. I take the call number from that file and not the array. it is numeric, and then seek it on the main table. the important lines are below, the IF FOUND line fails even though the number exists on the NWC file
>>
>>ADIR(myarray,'*.dbf')
>>mlength = ALEN(myarray,1)
>>FOR mx = 1 TO mlength STEP 1
>>   mfilename = morigloc + "\impcalls\" + myarray[mx,1]
>>   
>>   USE (mfilename) EXCLUSIVE ALIAS 'TEMPFILE1' in 0
> 
>>   cmalink = TEMPFILE1.CMA_calnum
>>   
>
>>   if SEEK(cmalink, 'NWC', 'CMA_calnum')
>>      WAIT WINDOW "Call already imported" TIMEOUT 2
>>   ELSE
>>   ...
>>
>>~M
>>
>>>
>>>Just a guess - could it be case / length of the expression issue?
>>>
>>>In other words, make sure to search for PADR(UPPER(FileName),length of the field)
>>>
>>>and use upper for the index.
>>>
>>>What is the exact expression of the index?
>>
>>
>>>>Hi,
>>>>I have a customer that transfers information between 2 systems. both are VFP applications and have the exact same file structure, VFP databases. I take a call from system A and create a dbf with the call number on it an dplace it in a particular folder, there are memo fields so I end up with 2 files 1234.dbf and 1234.fpt.
>>>>System B has an import button, when you click on it the code reads all of the files in a folder into an array and then checks the file name against the primary key field. if it find a match it skips the file, if not then it appends the contents of the file. the problem is that every so often a file might be exported a second time and therefore exist in the System B table but the code does not find a match on the primary key but when it goes to append it a primary key violation comes up. if i go out of the application and back in the problem still persists, it never finds the call number on the table but fails on the append.
>>>>I read the files in using
>>>>
>>>>ADIR(myarray,'*.dbf')
>>>>
>>>>and use a seek on the table using the index on the primary key
>>>>anyone any idea how to get around this?
>>>>~M
Go raibh maith agat

~M
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform