Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL Help Needed to Speed Up the code
Message
From
01/08/2013 14:50:47
 
 
To
01/08/2013 09:44:04
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP
Network:
Windows XP
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01579372
Message ID:
01579660
Views:
58
Thanks for the explaination but again, I am not exactly looking for the code you expained. Perhaps I am not able to express, what I am exactly asking.
That Match Filename is equal to Accountno is fine but where filename is not equal to accountno, I need differrent as explained below.
I have tables Master.DBF and a temporary cursor New_bills.
On the form the user 1st select Month and the Year and than the user clicks on a command button and selects the Target Path i.e the path where the files are to be copied. I have used GETDIR() for this.
Now suppose, the user selects
Combo1=July, Combo2=2013 and GETDIR()='C:\BILLS'
So, My cPath becomes
cPath = ADDBS(tDirectory+pBillmonth+'-'+ALLTRIM(STR(pbillyear))).
Uptill here every thing is fine.
Now I have suppose A, B, C, & D as FOUR Distinct Exchanges in Master.DBF,Taking the above Four exchanges My program creates FIVE Sub directories under cPath
A, B , C , D and an addtional 'MISSING EXCHANGE'

Now, I have to insert the new paths of Filename, filename is 10 Digit feild containing the names of files without extension Where New_bills.Filename is equal to Master.Account Number. I need to copy that path as Cpath plus the Corresponding exchange(A B C or D) and Where New_bills.Filename is not equal to Master.Account Number my newpath shall be Equal to 'C:\Bills\July-2013\Missing Exchnage\1234567899.ps

Mean to say that if the new_bills.Filename=Master.Accountno
Newpath=C:\Bills\July-2013\C\1234567899.ps. Suppose C is the corresponding exchage
and if new_bills.Filename<>Master.Accountno
Newpath=C:\Bills\July-2013\Missing Exchange\1234567899.ps
Please Note That "Missing Exchange" is NOT in the DISTINCT list of Master.Exchange
I tried to change your code, but could not get through. here is what i tried for those that DOES NOT MaTCH


cPath = ADDBS(tDirectory+pBillmonth+'-'+ALLTRIM(STR(pbillyear)))+'Missing Exchange'

* Handle the ones with no match.
UPDATE NewBills ;
  SET MissExg = 0, ;
          NewPath = FORCEPATH(FORCEEXT(Filename, "PS")+"\" , m.cPath)  ;
  WHERE FileName NOT IN (SELECT AccountNo FROM Master)
I am not having problem with the ones where Filename=Accountno. that code is working fine

Thanks in anticipation
****************************


***********




>>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
Harsh
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform