Subject AW: [firebird-support] problem using SELECT FIRST N in SP
Author ib-support
Hi Alan,

did you try this:

CREATE PROCEDURE GET_top_ten_1
RETURNS
(
nox1 numeric (9,2)
)
AS
begin
for select
First 1 nox
from releases
order by 1 desc
into :nox1
do
suspend;
end

Stefan

> -----Ursprüngliche Nachricht-----
> Von: firebird-support@yahoogroups.com
> [mailto:firebird-support@yahoogroups.com] Im Auftrag von
> Alan.Davies@...
> Gesendet: Samstag, 30. Juli 2005 08:27
> An: firebird-support@yahoogroups.com
> Betreff: [firebird-support] problem using SELECT FIRST N in SP
>
> Hi All - can anyone help with this? I want to select the top
> n from a table which works no problem using a select
> statement, but fails inside an SP
>
> This works with a single value
>
> CREATE PROCEDURE GET_top_ten_1
> RETURNS
> (
> nox1 numeric (9,2)
> )
> AS
> begin
> for select
> First 1 nox
> from releases
> order by nox desc
> into :nox1
> do
> suspend;
> end
>
> This version fails the compile but works fine as a sql
> statement This is the error message...
> Dynamic SQL Error
> SQL error code = -313
> count of column list and variable list do not match
>
> CREATE PROCEDURE GET_top_ten_2
> RETURNS
> (
> nox1 numeric (9,2),
> nox2 numeric (9,2)
> )
> AS
> begin
> for select
> First 2 nox
> from releases
> order by nox desc
> into :nox1,:nox2
> do
> suspend;
> end
>
>
> --
> Alan J Davies
> Aldis
> Tel: +44 (0)1926 842069
> Mob: +44 (0)7885 372793
>
>
> ------------------------ Yahoo! Groups Sponsor
> --------------------~-->
> <font face=arial size=-1><a
> href="http://us.ard.yahoo.com/SIG=12h5iqi80/M=362131.6882499.7
> 825260.1510227/D=groups/S=1705115386:TM/Y=YAHOO/EXP=1122711999
> /A=2889191/R=0/SIG=10r90krvo/*http://www.thebeehive.org
> ">Get Bzzzy! (real tools to help you find a job) Welcome to
> the Sweet Life - brought to you by One Economy</a>.</font>
> --------------------------------------------------------------
> ------~->
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Visit http://firebird.sourceforge.net and click the Resources item
> on the main (top) menu. Try Knowledgebase and FAQ links !
>
> Also search the knowledgebases at http://www.ibphoenix.com
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
>