Subject Re: Firebird record number
Author legrand_legrand_63
--- In firebird-support@yahoogroups.com, Alexandre Benson Smith
<iblist@...> wrote:
>
> legrand_legrand_63 wrote:
> >> Hi,
> >> i don't know if my trouble is about sql or about firebird but i
would
> >> like to return the record number of each record in a table,
> >> so a kind of :
> >> "select field1, field2..., recnumber as myfield from mytable.
> >>
> >> i try also with rownumber etc... but no success
> >>
> >> Thanks for your help
> >> Julien
> >>
> >>
> >
> >
> > Salut,
> > Firebird has a pseudo column called ROW_NUM that answer your question,
> > but it is only available in PSQL:
> > http://www.janus-software.com/fbmanual/manual.php?book=PSQL&topic=96
> >
> > With this ROW_NUM you should be able to write a procedure returning
> > the "rownumber" (In fact even without it, you should be able to write
> > a procedure counting records before to return them).
> >
> > And last Fyracle (Firebird Oracle-mode) has a rownum feature available
> > in its Firebird distribution
> > http://www.janus-software.com/runtime_dl.html (but please don't use it
> > for prod it is a frozen project ;o)
> >
> > Regards
> > PAscal
> >
> >
> >
>
> Pascal,
>
> I think there is some mis-information here.
>
> ROW_NUM should be a Fyracle implementaton to mimic Oracle's ROW_NUM as
> you said Fyracle ir Oracle Mode Firebird.
>
[...]

Alexandre,
I apologize, you are perfectly right
ROWNUM is an Oracle (and Fyracle) pseudo columns.
But Firebird implements ROW_COUNT (in PSQL only)
try this:

CREATE PROCEDURE RECORDNUM
RETURNS (
NUM INTEGER,
NAME CHAR(31))
AS
begin
For
select
row_count,
rdb$relation_name from rdb$relations
into :num, :name
do
begin
suspend;
end
end^

that would have been great to have it directly in SQL ;o)

Regards
PAscal