L
LarryP
I have a query (full SQL below) that's used in a procedure which promotes
records through a sequence of "gates" involved in a material handling
process. Sometimes, a promotion can bypass gates, e.g., item(s) can move
from gate 2 directly to gate 5. This query looks through a table and finds
records where (a) the batch flag is on and (b) the "to" gate is > 1 above the
"from" gate. (I can't just assume that because 100 items were flagged, all
of them involve a bypass; some may be moving only one gate, others may jump
three or four). Whenever those conditions are met, it creates a new record
in a comments table identifying the fact that certain gates were bypassed.
I have it running fine, but it's a bit slower than I like when mucho records
are flagged. I ascribe that to the fact that it has to run a function twice
against each record. The function determines (via a DLookup) what the "from"
gate is, which is needed both for the selection criterion and to build the
"gate x to y" comment string for the output.
Would welcome any ideas on ways this can be streamlined to run faster.
******************** SQL *****************************
INSERT INTO tblLICommentLog ( LIIDNo, GateNo, LogonID, CommentDateTime,
Remarks )
SELECT tblContractLIData.LIIDNo, GetBatchPromoteTargetGate() AS Expr1,
Environ("UserName") AS Expr2, Date() AS Expr3, "LI BYPASSED GATE(S) " &
GetCurrentActiveGate([LIIDNo])+1 & " THRU " & GetBatchPromoteTargetGate()-1
AS Expr4
FROM tblContractLIData
WHERE (((tblContractLIData.BatchFlag)=True) AND
(([CurrentActiveGate]<(GetBatchPromoteTargetGate()-1))=True));
records through a sequence of "gates" involved in a material handling
process. Sometimes, a promotion can bypass gates, e.g., item(s) can move
from gate 2 directly to gate 5. This query looks through a table and finds
records where (a) the batch flag is on and (b) the "to" gate is > 1 above the
"from" gate. (I can't just assume that because 100 items were flagged, all
of them involve a bypass; some may be moving only one gate, others may jump
three or four). Whenever those conditions are met, it creates a new record
in a comments table identifying the fact that certain gates were bypassed.
I have it running fine, but it's a bit slower than I like when mucho records
are flagged. I ascribe that to the fact that it has to run a function twice
against each record. The function determines (via a DLookup) what the "from"
gate is, which is needed both for the selection criterion and to build the
"gate x to y" comment string for the output.
Would welcome any ideas on ways this can be streamlined to run faster.
******************** SQL *****************************
INSERT INTO tblLICommentLog ( LIIDNo, GateNo, LogonID, CommentDateTime,
Remarks )
SELECT tblContractLIData.LIIDNo, GetBatchPromoteTargetGate() AS Expr1,
Environ("UserName") AS Expr2, Date() AS Expr3, "LI BYPASSED GATE(S) " &
GetCurrentActiveGate([LIIDNo])+1 & " THRU " & GetBatchPromoteTargetGate()-1
AS Expr4
FROM tblContractLIData
WHERE (((tblContractLIData.BatchFlag)=True) AND
(([CurrentActiveGate]<(GetBatchPromoteTargetGate()-1))=True));