Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Why the last SQL stmt should take so long
Message
From
28/04/1999 09:13:57
 
 
To
28/04/1999 00:10:23
David Abraham
David Abraham & Associates, Inc.
New York City, New York, United States
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00212871
Message ID:
00212939
Views:
23
>The following code works, it prints "Pick Tickets" for a Mail Order house. But for the life of me, I can't figure out why the last piece of the puzzle, PTLinePart, the last Procedure of four, takes 90+% of the entire PicTicView's time.
>
>David
>
>+++++++++++++++++++++++++++++++++++++++++++
>
>*** Print Pick Tickets
>PROCEDURE PickTick
>LPARAMETERS condition
>PUBLIC lcCCNo, lcExpDate, lnAmt, mainphone
>DO PicTicView WITH condition
>REPORT FORM rptPickTick TO PRINTER PREVIEW
>RELEASE lcCCNo,lcExpDate, lnAmt, mainphone
>RETURN
>
>
>PROCEDURE PicTicView
>LPARAMETERS condition
>DO PTBasicPart WITH condition
>DO PTShipPart
>DO PTBillPart
>DO PTLinePart
>RETURN
>
>
>PROCEDURE PTBasicPart
>LPARAMETERS condition
>sql_stmt = ;
> "SELECT " ;
>+ "ord_id, ord_no, ord_date, ord_taxamt / ord_stotal * 100 AS tax_rate,
>comp_abbr, order_type, ost_desc, empl_abbr " ;
>+ "FROM ord_hdrs hdr " ;
>+ "JOIN company com ON hdr.comp_id = com.comp_id " ;
>+ "JOIN ordtypes oty ON hdr.otyp_id = oty.otyp_id " ;
>+ "JOIN ord_stat ost ON hdr.ost_id = ost.ost_id " ;
>+ "JOIN employee emp ON hdr.empl_id = emp.empl_id " ;
>+ "WHERE " + condition + " " ;
>+ "ORDER BY ord_no " ;
>+ "INTO CURSOR Temp1"
>&sql_stmt
>RETURN
>
>
>PROCEDURE PTShipPart
>SELECT t1.*, osh_no, ;
>cst_no AS scst_no, ALLTRIM(cst_fname) + ' ' + cst_lname AS scst_name,
>cst_add1 AS scst_add1, cst_add2 AS scst_add2, ;
>ALLTRIM(city) + ' ' + ALLTRIM(st) + ', ' + ALLTRIM(post_code) +
>IIF(ctry_abbr = 'USA','',' '+ctry_abbr) AS saddrest, ;
>TRAN(cst_phone1,'@R '+ ctry_fpatt) AS sphone, ;
>osh_date AS ship_date, osh_shpamt AS shipamt, osh_cspdel AS spdel, osh_ccod
>AS cod, shmth_abbr + carr_abbr AS shipvia ;
>FROM Temp1 t1 ;
>JOIN ord_ship shp ON t1.ord_id == shp.ord_id ;
>JOIN customer cst ON shp.cst_id == cst.cst_id ;
>JOIN postcode pos ON cst.post_id == pos.post_id ;
>LEFT JOIN country cty ON cst.ctry_id == cty.ctry_id ;
>LEFT JOIN shipmeth shm ON shp.shmth_id == shm.shmth_id ;
>LEFT JOIN carriers car ON shp.carr_id == car.carr_id ;
>ORDER BY ord_no, osh_no ;
>INTO CURSOR Temp2
>RETURN
>
>
>PROCEDURE PTBillPart
>SELECT t2.*, ;
>cst_no AS bcst_no, ALLT(cst_fname) + ' ' + cst_lname AS bcst_name, cst_add1
>AS bcst_add1, cst_add2 AS bcst_add2, ;
>ALLTRIM(city) + ' ' + ALLTRIM(st) + ', ' + ALLTRIM(post_code) +
>IIF(ctry_abbr = 'USA','',' '+ctry_abbr) AS baddrest, ;
>TRAN(cst_phone1,'@R '+ ctry_fpatt) AS bphone, ;
>TRAN(obl_ccno,'@R '+cc_pattern) AS ccno,
>LEFT(obl_ccexp,2)+'/'+RIGHT(obl_ccexp,2) AS ccexp, obl_ccauth AS ccauth,
>obl_amt ;
>FROM Temp2 t2 ;
> JOIN ord_bill bil ON t2.ord_id == bil.ord_id AND bil.obl_no = '1' ;
> LEFT JOIN credcard crc ON bil.cc_id == crc.cc_id ;
> LEFT JOIN paymeths pym ON bil.pmth_id == bil.pmth_id AND pay_abbr = "CC" ;
> JOIN customer cst ON bil.cst_id == cst.cst_id ;
> JOIN postcode pos ON cst.post_id == pos.post_id ;
> LEFT JOIN country cty ON cst.ctry_id == cty.ctry_id ;
>ORDER BY ord_no, osh_no ;
>INTO CURSOR Temp3
>RETURN
>
>
>PROCEDURE PTLinePart
>SELECT t3.*, ;
>orl_lineno, bko_qty, ship_qty, storprcode, prod_descr, orl_scost,
>orl_price, orl_exten ;
>FROM Temp3 t3 ;
> JOIN ord_dtls dtl ON dtl.ord_id == t3.ord_id AND dtl.osh_no == t3.osh_no ;
> JOIN products pro ON pro.prod_id == dtl.prod_id ;
>ORDER BY ord_no, t3.osh_no, orl_lineno ;
>INTO CURSOR Temp4
>RETURN


Take a look at the article on Rushmore on my web site.
Craig Berntson
MCSD, Microsoft .Net MVP, Grape City Community Influencer
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform