Subject | Re: [firebird-support] Return integer row_id in record set |
---|---|
Author | Ronan van Riet |
Post date | 2011-07-26T21:30:19Z |
Thanks to all who responded to my question.
For the benefit of others I created a stored procedure, similar to below, to resolve the issue.
SET TERM ^ ;
CREATE PROCEDURE GET_X
RETURNS (
ID Integer,
VAL Integer )
AS
BEGIN
ID=0;
FOR SELECT ID
FROM X
WHERE "TIME" = 0
ORDER BY ID
INTO :VAL
DO BEGIN
ID=ID+1;
SUSPEND;
END
END^
SET TERM ; ^
Regards,
Ronan
For the benefit of others I created a stored procedure, similar to below, to resolve the issue.
SET TERM ^ ;
CREATE PROCEDURE GET_X
RETURNS (
ID Integer,
VAL Integer )
AS
BEGIN
ID=0;
FOR SELECT ID
FROM X
WHERE "TIME" = 0
ORDER BY ID
INTO :VAL
DO BEGIN
ID=ID+1;
SUSPEND;
END
END^
SET TERM ; ^
Regards,
Ronan
----- Original Message -----
From: Ronan van Riet
To: firebird-support@yahoogroups.com
Sent: Saturday, July 23, 2011 11:34 AM
Subject: [firebird-support] Return integer row_id in record set
Hello,
I wish to display the ID (of all time points = 0). I can handle this programatically but rather would do in SQL.
The following query returns the time points
SELECT ID as VAL
FROM x
WHERE "TIME" = 0
order by id
The values are
87
117
120
Now, is there a function in FB that will return me an ID (sequential, starting at 1 and increments of 1) for each of the records like so?
ID VAL
1 87
2 117
3 120
Thanks in advance,
Ronan
[Non-text portions of this message have been removed]
[Non-text portions of this message have been removed]