Consider the code, which is in file temp.prg:

SET VAR tDays = -5


SET VAR tDateTime DATETIME = (ADDDAY(.#NOW, .tDays))

  SELECT (LISTOF(DIST PQCResult) + ':' & SRPL(PQCTestText, CHAR(10), ' - ', 
0)), COUNT(*) +

    FROM PartOpResults POR, PartPQCResults PPR, PQCTestCache PTC +
    WHERE POR.ResultID = PPR.ResultID AND PPR.PQCTestID = PTC.PQCTestID  +
      AND MachineID = .fBLM_MachineID AND OpNum = .fBLM_OpNum AND OpResult >= 
.tDateTime AND PQCResult <> 'A' +
      AND BatchNum IN (SELECT DISTINCT BatchNum FROM PartSerl WHERE WONum = 
.fBLM_WONum AND Class IN ('B', 'NC', 'RWK', 'Q')) +
    GROUP BY PQCTestText

SET VAR tDate DATE = (ADDDAY(.#DATE, .tDays))

  SELECT ('NC:' & DefectDesc), COUNT(*) FROM NonConform NC, NCDefectCodes DC +

    WHERE NC.OGNCDefectCode = DC.DefectCode +
      AND MachineID = .fBLM_MachineID AND OpNum = .fBLM_OpNum AND 
ManufactureDate >= .tDate +
      AND BatchNum IN (SELECT DISTINCT BatchNum FROM PartSerl WHERE WONum = 
.fBLM_WONum AND Class IN ('B', 'NC', 'RWK', 'Q')) +
    GROUP BY DefectDesc

If I run temp.prg from the R> prompt, it executes in .2 seconds (two tenths of 
a second).

If I do RUN temp.prg from inside a form, the same code takes 3.6 seconds, 
almost 20 times as long, to execute.

I am not changing any variable values in my code that might affect lookups on 
the form.  The form is a variable form. 

Does anyone know what could be causing the difference, and how I can work 
around it?
--
Larry

Reply via email to