Ya parece que sí funciona !
Código SQL
[-]begin
Select BOJ.BOOKINGNO
from BOOKINGS_OBJECTS BOJ
left join BOOKINGS BO
on BO.BOOKINGNO = BOJ.BOOKINGNO
where
BOJ.BUILDINGNO = :"BUILDING_NO" and
BOJ.OBJECTNO = :"OBJECT_NO" and
BOJ.DATETO <= :"DATE_SP" and
BO.STATUS = 3
Into BOOK_NO;
if (not :"BOOK_NO" is Null) then
SUSPEND;
else begin
Select BOJ2.BOOKINGNO
from BOOKINGS_OBJECTS BOJ2
left join BOOKINGS BO2
on BO2.BOOKINGNO = BOJ2.BOOKINGNO
where
BOJ2.BUILDINGNO = :"BUILDING_NO" and
BOJ2.OBJECTNO = :"OBJECT_NO" and
BOJ2.DATEFROM <= :"DATE_SP" and
BOJ2.DATETO >= :"DATE_SP" and
BO2.STATUS <= 2
Into BOOK_NO;
SUSPEND;
end
end