Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Any ideas to index/speed this up?
Message
From
18/07/2003 01:24:54
Lutz Scheffler (Online)
Lutz Scheffler Software Ingenieurbüro
Dresden, Germany
 
 
To
17/07/2003 15:51:59
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00810823
Message ID:
00811390
Views:
9
Hi Steve,
for the first could you post the code snippets in pre html tags. This will make it more readable. If you do not know how check UT's help or simple reply this message and have a look at the pre html tags. ::)

Do you refer to my last message? I'm a little bit confused.

All what I say is that an RELATION will allways be like EXACT ON if set SET EXACT OFF will not matter.

I see the failure in may select know. ::) It gives you those short codes as well as the long ones

so you need to ged rid of the small codes
SELECT cdr && cdr is call records in previous
SET ORDER TO _Primary	     &&your Primary key
*or
INDEX ON UniqueID TAG _UNI	&&whatever makes a record unique

SET EXACT OFF
SELECT;
 Cur2.UniqueID                                    AS CDR_Uni,;			&&something that makes a record in cdr unique, just the same as above
 Cur1.DEST                                        AS CDR_Dest,;
 Cur1.CODE                                        AS CDR_Code,;
 Cur1.Rate                                        AS CDR_Rate,;
 Cur2.Duration                                    AS CDR_Duration,;
 IIF(Cur2.Duration >0,;
  IIF(Cur2.Duration<Cur1.MinimumSec,;
   (Cur1.MinimumSec/60),
   (CEILING(Cur2.Duration/Cur1.INCREMENT)/60*Cur1.INCREMENT)),;
  0)                                             AS CDR_billdur,;
 IIF(Cur2.Duration > 0,Cur1.Rate*Cur2.billdur,0) AS CDR_Charge;			&&MayBe You need do that down in the replace because of first normalising BillDur
 FROM Rate AS Cur1,;
 INNER JOIN cdr AS Cur2;
 ON ALLTRIM(Cur2.dnis)=Cur1.CODE;
 AND !EMPTY(Cur2.DEST);
 INTO CURSOR curHelp
*this gives Code "0115411"  as well as "01154" for  dnis="0115411555555"
*************** new part **************************
now lets see how get rid of it
SELECT;
 Cur1.CDR_Uni,;
 Cur1.CDR_Code,;
 MAX(LEN(ALLTRIM(Cur1.CDR_Code);
 FROM curHelp;
 INTO CURSOR curSum;
 GROUP BY 1,2 
*only the longest codes for a CDR_Uni should survive

SELECT;
 Cur1.CDR_Uni,;
 Cur1.CDR_Dest,;
 Cur1.CDR_Code,;
 Cur1.CDR_Rate,;
 Cur1.CDR_Duration,;
 Cur1.CDR_billdur,;
 Cur2.CDR_Charge;
 FROM curHelp AS Cur1,;
 INNER JOIN curSum AS Cur2;
 ON Cur2.CDR_Uni==Cur1.CDR_Uni;
 AND Cur2.CDR_Code==Cur1.CDR_Code;
 INTO CURSOR curHelp1
*now we should have the rates for the longest possible code

*************** /new part **************************

SET RELATION TO CDR_Uni INTO CDR
*This is a 1 To 1 relation so no need to SET SKIP
REPLACE;
 CDR.Rate    WITH CDR_Rate,;
 CDR.DEST    WITH CDR_Dest,;
 CDR.CODE    WITH CDR_Code,;
 CDR.BillDur WITH CDR_BillDur,;
 CDR.Charge  WITH CDR_Charge;
 ALL

SET RELATION TO
USE
USE IN curSum
USE IN curHelp
SELECT cdr
SET ORDER TO
if you

>Thanks Agnes,
>
>The code I put up was rating all the calls, just not on the longest rate that matched the DNIS [dialed number]
>
>For instance lets say you make a call to "Argentina-Buenos Aires"
>The number you called is 0115411555555
>
>the dial code for buenos aires is "0115411" and .0128 cents per minute.
>the dial code for all of argentina, that does not match a longer rate code is 01154 at .0285 cents per minute.
>
>For some reason the code I put up(based on Dan's code) is rating all the calls to the shortest match (Argentina) instead of the longest match (Buenos Aires). Even though when I browse the tables related like the code (I'll put below) it shows the longer dial codes 1st, and displays the proper calls for the dial codes.
>
>
>SELECT cdr
> INDEX ON dnis TAG dnis
>SELECT rate
> INDEX ON code TAG code desc
>SET RELATION TO ALLTRIM(code) INTO cdr
>browse rate
>browse cdr
>
>this displays in the rate browse window (to stick with Argentina example)
>01154221 Argentina-La Plata
>0115411 Argentina-Buenos Aires
>01154 Argentina
>
>Your call to 0115411555555 shows up under both 0115411 and 01154.
>
>
>To compensate for this Dan had his code only replacing the charge and rate fields within your call record if they were still blank. They would be blank when buenos aires was reached and would be replaced with the values from the rate table. Then when the rating program reached Argentina it would still look at your call again, but the charge field would no longer be blank, so it wouldn't change it
>REPLACE...........FOR EMPTY(cdr.rate) Here's that code.
>
>SELECT cdr
> INDEX ON dnis TAG dnis
>SELECT rate
> INDEX ON code TAG code desc
>SET RELATION TO ALLTRIM(code) INTO cdr
>SET SKIP TO cdr
>REPLACE cdr.rate WITH rate ;
>, cdr.charge with IIF(cdr.duration>0,rate*cdr.billdur,0) :
>FOR empty(cdr.rate)
>
>I've tried changing it around, adding a "do while not eof" loop after setting the relation.
>
>Do while not eof()
>replace......for empty(cdr.rate)
>enddo
>
>then I added an if instead of the for clause (and tried both as well)
>
>Do while not eof()
>If empty(cdr.rate)
>replace......
>endif
>enddo
>
>and I keep ending up with your call getting rated to argentina instead of buenos aires. I'm not sure if the program is hitting the short rates 1st, or if it is just disregarding commands to only do replace operations on empty fields. I suspect the former, but can't figure out why.
>
>Sorry this is so long, just wanted to make it clear.
Words are given to man to enable him to conceal his true feelings.
Charles Maurice de Talleyrand-Périgord

Weeks of programming can save you hours of planning.

Off

There is no place like [::1]
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform