BEGIN
IF (:ABusTransactionWithChildren IN ('1', 'A')) THEN BEGIN
/* vcetne podrizenych */
SELECT COUNT(*)
FROM BusTransactions Bx
WHERE ((Bx.ID = :ABusTransaction_ID) OR ((:ABusTransactionWithNull IN ('1', 'A')) and (:ABusTransaction_ID is null))) AND (Bx.Hidden = 'N') AND
( (Bx.ID in (select OBJ_ID from SELDAT where SEL_ID = :ABusTransactionSel_ID)) OR
(Bx.ID in (select ID from SYS$BusTransactions2 where Superior_ID in (select OBJ_ID from SELDAT where SEL_ID = :ABusTransactionSel_ID))) )
INTO :ABoolResult;
END
ELSE BEGIN
/* pouze za ty vybrane bez podrizenych */
SELECT COUNT(*)
FROM BusTransactions Bx
WHERE ((Bx.ID = :ABusTransaction_ID) OR ((:ABusTransactionWithNull IN ('1', 'A')) and (:ABusTransaction_ID is null))) AND (Bx.Hidden = 'N') AND (Bx.ID in (select OBJ_ID from SELDAT where SEL_ID = :ABusTransactionSel_ID))
INTO :ABoolResult;
END
END;