R
rayherring
Guest
Do you really need to do the self-join? from what i am seeing in your query, there is no reason why you are doing some of it. Couldn't you simply do: FOR EACH Table_A NO-LOCK WHERE DATE(Table_A.DATE_Time_Updated) = DATE("03/06/2009") AND ( Table_A.QSA_Approved = YES OR Table_A.QSA_Approved = NO), EACH Table_B NO-LOCK WHERE Table_B.Source_ID = Table_A.SOURCE_Id BY Table_B.SOURCE_Id BY Table_A.DATE_Time_Updated DESC: END. ??? Would save a lot of query time i would think. If you want to do a dynamic query (where input data could cause a change in how the query itself is structured) then you want to use a query itself. def var hquery as handle. def var cwhere as character. cWhere = "FOR EACH Table_A NO-LOCK". cWhere = cWhere + " WHERE DATE(Table_A.DATE_Time_Updated) = DATE(03/06/2009)". cWhere = cWhere + ", EACH Table_B NO-LOCK WHERE Table_B.Source_ID = Table_A.Source_ID". open query hquery. hquery:add-buffer(buffer Table_A). hquery:add-buffer(buffer Table_B). hquery:query-prepare(cWhere). hquery:query-open(). Though that is all taken from memory as i don't have my normal work pc in front of me.
Continue reading...
Continue reading...