Subject Re: [firebird-support] Stored procedure
Author Milan Babuskov
Datatal AB - Gauffin, Jonas wrote:
> I want to create a stored procedure that checks a column after a gap (seatbooking, if seats 1,2,4 are booked it should return 3. If seats 1,2,3,4 is booked it should return 5)
>
> my procedure complains on the INTO line.

It complaints about ; after INTO. But you procedure is not likely to do
what you want anyway. You can get the value you need with one select:

select min(platsnr) + 1
from bokning b
inner join bokning_passagerare bp on (b.bokningsnr=bp.bokningsnr)
where b.flight_nr = :avg_datum
AND b.avg_datum = :flightnr
where not exists (
select *
from bokning b2
inner join bokning_passagerare bp2 on
(b2.bokningsnr=bp2.bokningsnr)
where b2.flight_nr = :avg_datum
AND b2.avg_datum = :flightnr
and bp2.platsnr = b.platsnr + 1
)

Of course, you can put this into a SP.

HTH

--
Milan Babuskov
http://fbexport.sourceforge.net