begin
if ((ADateFrom = 0) or (ADateTo = 0)) then begin
/* Pokud není zadáno časové omezení, nebereme ohled na období platnosti výrazu. */
for
select B.ID, A.ID
from CalcCharts A
left join CalcExpressions B on A.ID=B.Parent_ID
where (A.CLSID = :ACLSID) and (B.FieldCode = :AFieldCode)
into :Expr_ID, Chart_ID
do begin
suspend;
end
end else begin
for
select B.ID, A.ID
from CalcCharts A
left join CalcExpressions B on A.ID=B.Parent_ID
where
(A.CLSID = :ACLSID) and (B.FieldCode = :AFieldCode) and
B.ID in (select ID from
GetCalcExpressionsByDate(B.Parent_ID, :ADateFrom, :ADateTo)
)
into :Expr_ID, Chart_ID
do begin
suspend;
end
end
end;