CREATE OR ALTER PROCEDURE NEW_PROCEDURE2 (in_random decimal(12,0))
returns (out_random decimal(12,0))
as
declare variable aux_rand decimal(12,0);
declare variable aux_true integer;
begin
AUX_TRUE = 0;
while (:AUX_TRUE = 0) do
begin
aux_rand = null;
Select RANDOMNO from PRUEBA
where RANDOMNO = :IN_RANDOM
rows 1 into AUX_RAND;
if (:AUX_RAND is null) then
begin
Leave;
end
else
begin
IN_RANDOM = :IN_RANDOM + 1;
if (:IN_RANDOM > 200) then
Leave;
end
end
OUT_RANDOM = IN_RANDOM;
suspend;
end