General information
Category:
Databases,Tables, Views, Indexing and SQL syntax
>SELECT * FROM PRO_SCHT INTO CURSOR PROSCHT WHERE ALLTRIM(PRO_SCHT.SPFLAG)="*"
>SELECT 0000000000.000 AS CNTRANGE ,* FROM proscht a INTO DBF &pscht where EXISTS(SELECT * FROM PROD_TRAN b WHERE (a.p_number=b.p_number AND ALLTRIM(b.TRANNUMBER)=ALLTRIM(m.trannumber)))
>
I think your problem has to do with the EXISTS subquery. When you use EXISTS and reference fields from the main query in the subquery (that's called a "correlated subquery"), FoxPro has to run the subquery for each record in the main query. If you can rewrite it using IN and a subquery that's not correlated, it should speed up. And the good news is that any EXISTS subquery can be rewritten as an IN subquery.
WHERE a.p_number + ALLTRIM(a.TRANNUMBER) IN ;
(SELECT b.p_number + ALLTRIM(m.trannumber) FROM PROD_TRAN b)
Of course, you have to make sure the expression is all character and will match correctly.
Tamar
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only