Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Any ideas to index/speed this up?
Message
From
18/07/2003 12:42:08
 
 
To
18/07/2003 01:24:54
Lutz Scheffler
Lutz Scheffler Software Ingenieurbüro
Dresden, Germany
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00810823
Message ID:
00811537
Views:
7
Thanks for you help Agnes, I'm a little confused about what you're doing in your code. I'm not real good with SQL and having a hard time trying to implement this without understanding what's happening.

Could you just give a little overview of what the different sections of your code are doing? I'm especially confused by the cur1 and cur2 below, should I just substitute the rate table alias, and cdr table alias for them? And I don't see how the 2 tables are relating, I'm not seeing how it grabs the rates (including shorter duplicate rates) for each call?
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
No problem here, CDR.DNIS and CDR.StartDT (Datetime field as character field)will be my unique id
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,;
Here's where I get confused, are you just making empty fields for the rate table data, or are we somehow pulling all the rate.code(s) that match the DNIS(s)?
 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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform