SQL-Code:
SET TERM ^;
create procedure nextFreeLiefNumber ( lBound char(7), uBound char(7))
returns (A_RETURN INTEGER) AS
declare freienummer double;
begin
For
SELECT o.L1_NR as freienummer FROM FLIEF_1 o where o.L1_nr between lBound and uBound
AND NOT EXISTS (SELECT i.L1_NR FROM FLIEF_1 i
WHERE cast(i.L1_NR as double precision) = cast(o.L1_NR as double precision) + cast(1 as double precision)) into :freienummer do
A_RETURN = cast(freienummer as double precision)+1;
suspend;
end
SET TERM ;^
getiipt und nicht getestet.