begin
if (:ASelID <> '') then begin
if (:APutToFrom in ('1', 'A')) then begin --to :ASelID pouzivam i jako cast ALIAS pro SELDAT, kterych muze ve from byt vic
SQLSeldatAlias = 'Sld' || ib_string_replace(ASelID, '~', 'X');
AResult = ' join Seldat ' || :SQLSeldatAlias || ' on ' || :SQLSeldatAlias || '.SEL_ID = ''' || :ASelID || ''' and ' || :SQLSeldatAlias || '.OBJ_ID = ' || AField;
end else begin
Select AResult from SYS$CONCATSELECT('OBJ_ID', 'SELDAT where SEL_ID = ''' || :ASelID || '''') into :SQLConc;
if (:AHideForOptimazation in ('1', 'A')) then
AResult = :AField || ' || '''' in (' || :SQLConc || ')';
else
AResult = :AField || ' in (' || :SQLConc || ')';
end
end else
AResult = null;
suspend;
end;