Subject RE: [firebird-support] problem using SELECT FIRST N in SP
Author Alan.Davies@aldis-systems.co.uk
Quoting Alan McDonald <alan@...>:
> Alan, You can only do this by select (not with the First clause) but use the
> order by clause with an arbitrary counter which exits the SP when the
> counter reaches 2. You will also need to select into the same variable and
> return 2 rows of this variable, not 2 fields in the one row.
> Alan

CREATE PROCEDURE GET_top_ten_2
RETURNS
(
nox1 numeric (9,2)
)
AS
declare variable low_high integer;
begin
low_high=1;
while (low_high<3) do
begin
for select
nox
from releases
order by nox desc
into :nox1
do
suspend;
end
low_high=low_high+1;
end


Thanks - I guess I want something along these lines. Except.... my version
doesn't work yet - it gives empty results. Still, I'll persevere, or drop the
idea and go back to my original "select first 12 ... from ..." version (I'm
just showing 2 here for simplicity... there are dates, times, etc as
well)which
I run from within Delphi. I just thought this would be a more elegant,
cross-platform idea, since I have linux and windows versions and am
investigating a web-based front-end hence the desire to change to an SP; but
it's taking far too much time.
Thanks for your input, though.
Alan

--
Alan J Davies
Aldis
Tel: +44 (0)1926 842069
Mob: +44 (0)7885 372793