Subject | Re: [firebird-support] ROW_NUMBER |
---|---|
Author | Milan Babuskov |
Post date | 2007-02-15T22:02:35Z |
Lele Gaifax wrote:
Anyway, bad idea in multiuser environment.
using EXECUTE BLOCK.
--
Milan Babuskov
http://www.guacosoft.com
http://www.flamerobin.org
>>Hi, is there a way to have a RowNumber for each row returned by aWhy not simply: SET GENERATOR rownum TO 0;
>>query?
> The following stmt will bring the generator
> back to zero:
>
> SELECT gen_id(rownum, -gen_id(rownum, 0) FROM rdb$database
Anyway, bad idea in multiuser environment.
> CREATE PROCEDURE CountingMyTableIf you use Firebird 2.0, you can do the same without stored procedure by
> RETURNS (rownum INTEGER, fld1 SomeType, fld2 SomeOtherType) AS
> BEGIN
> rownum = 0;
> FOR SELECT mt.fld1, mt.fld2
> FROM MyTable mt
> ORDER BY 2,1
> INTO fld1, fld2 DO
> BEGIN
> rownum = rownum+1;
> SUSPEND;
> END
> END
using EXECUTE BLOCK.
--
Milan Babuskov
http://www.guacosoft.com
http://www.flamerobin.org