Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL Help Needed to Speed Up the code
Message
De
01/08/2013 09:44:04
 
 
À
31/07/2013 13:57:53
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP
Network:
Windows XP
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01579372
Message ID:
01579641
Vues:
90
>Madam, the following code didn't worked properly, It replaced Newpath with only 'Missing Exchange' while I was trying to get in Newpath as 'C:\JUl-2013\Missing Exchage\123.ps'
>
>Means In my destination path ("c:\JUL-2013") I have created Many Sub folders from the Distinct Master.Exchange and now I am copying files in that each folder. Apart from those folder I have also created a folder "Missing Exchange" and want to keep newpath as 'C:\JUL-2013\Missing Exchage\123.ps' for those files which do not have corrosponding account or exchange code in Master.dbf
>
>I Have my main path as cPath = ADDBS(tDirectory+pBillmonth+'-'+ALLTRIM(STR(pbillyear))).
>
>This code replaced all Newpath with 'Missing exchange', while I needed 'C:\JUL-2013\Missing Exchange\123.ps' in Newpath
>
>
>
>* Handle the ones with no match.
>UPDATE NewBills ;
>  SET MissExg = 0, ;
>         NewPath = "Missing Exchange";
>  WHERE FileName NOT IN (SELECT AccountNo FROM Master)
>
>
>
>Actually, Missing Exchange is the Folder in which I will copy files whose Account Number is not available in the master.dbf
>
>I tried to change the above code as given below, and tried many combinations , but didn't worked.
>
>
>* Handle the ones with no match.
>
>cPath = ADDBS(tDirectory+pBillmonth+'-'+ALLTRIM(STR(pbillyear)))+'Missing Exchange\'
>
>* Handle the ones with no match.
>  UPDATE New_Bills ;
>	  SET MissExg = 0, ;
>          NewPath = FORCEPATH(FORCEEXT(FileName, "PS"),m.cPath) ;
>  WHERE FileName NOT IN (SELECT AccountNo FROM Master)
>
>
>
>Although, I have got the solution to my initial problem but again asking you to learn.
>
>Also please tell me , when the variable cPath was used , than how it became m.cpath in next line
>

So you need something like:
cPath = ADDBS(tDirectory+pBillmonth+'-'+ALLTRIM(STR(pbillyear)))

* Handle the ones that match first.
UPDATE NewBills ;
  SET MissExg = 1, ;
          NewPath = FORCEPATH(FORCEEXT(FileName, "PS")+"\" + ALLTRIM(Master.Exchange), m.cPath) ;
  FROM Master ;
  WHERE NewBills.FileName = Master.AccountNo

* Handle the ones with no match.
UPDATE NewBills ;
  SET MissExg = 0, ;
          NewPath = FORCEPATH(FORCEEXT("Missing Exchange", "PS")+"\" + ALLTRIM(Master.Exchange), m.cPath)  ;
  WHERE FileName NOT IN (SELECT AccountNo FROM Master)
The "m." indicates that I'm referring to a variable, not a field. Using it is a best practice to ensure that you get the results you expect. When you use a name in code that could be either a variable or a field, VFP first looks for a field. If there's no such field in the current workarea, then it checks for a variable. Putting "m." in front says look only for a variable. It's pretty much the same idea as putting the alias for a table in front of a field name, as I did with "Master.Exchange".

Tamar
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform