I have the below function that takes quite long to run on
a report. Is there a way for me to optimized it to perform
the query quicker. I appreciate any help anyone can give me.
Thanks.
Rick
a report. Is there a way for me to optimized it to perform
the query quicker. I appreciate any help anyone can give me.
Thanks.
Rick
Code:
PARAMETER HID,STW,STL
LOCAL F,RECTRANS
F=ALIAS()
RECTRANS=''
SET OPTIMIZE ON
SELECT DATE_STAMP,PO,LINE_NO,QUANTITY,PRICE,E_ID FROM;
INVTRANS WHERE TYPE='1' AND ID=HID AND STOCK_W=STW AND;
STOCK_L=STL AND TRANS_TYPE=2 AND DATE_STAMP>DATE()-365;
ORDER BY DATE_STAMP INTO CURSOR IT
SELECT IT
SCAN
STOCK_L=STL AND TRANS_TYPE=2 AND DATE_STAMP>DATE()-365
RECTRANS=RECTRANS+ALLTRIM(STR(MONTH(DATE_STAMP)))+'/';
+ALLTRIM(STR(DAY(DATE_STAMP)))+'/'+ALLTRIM(STR(YEAR(DATE_STAMP)));
+SPACE(2)+PO+SPACE(2)+LINE_NO+SPACE(2)+STR(QUANTITY,11,3)+SPACE(2);
+STR(PRICE,12,3)+SPACE(2)+E_ID+CHR(13)
ENDSCAN
USE IN IT
SELECT (F)
RETURN RECTRANS