Firebird: Generate a range of numbers.

PHOTO EMBED

Tue Sep 17 2024 20:04:02 GMT+0000 (Coordinated Universal Time)

Saved by @marcopinero #sql

create procedure generate_range(startvalue integer, endvalue integer)
    returns (seq integer)
as
begin
    seq = startvalue;
    suspend;

    while (seq < endvalue) do
    begin
        seq = seq + 1;
        suspend;
    end
end;

/* Ex: select seq from generate_range(1, 100); */
content_copyCOPY