Subject RE: [firebird-support] Sql
Author agung wibowo
>Hello
>
> Fb 1.5.1
>
> I have a table currently loaded
> with 300,000 rows .
>
> //here is the meta
>
> CREATE TABLE FDET (
> RNO INTEGER
>, EPOCH INTEGER
>, MSE DECIMAL ( 18, 10 )
>, TRAINTIME TIMESTAMP
>)
>
> I would like to have a query which returns
> every 1000 row , so the resultset would have
> 300 records.
>
> The table is sorted on rno desc .
>
> How would the sql look like ?



Hi,

Try this, if I'm not wrong about my understood.



SET TERM ^;

CREATE PROCEDURE GET_FDET (MAX_REC INTEGER, COL INTEGER)

RETURNS (
RNO INTEGER,
EPOCH INTEGER,
MSE DECIMAL ( 18, 10 ),
TRAINTIME timestamp)

AS

DECLARE VARIABLE LINESTART INTEGER;

BEGIN

LINESTART=MAX_REC*(COL-1);

LINESTART=LINESTART+1;

SELECT FIRST MAX_REC SKIP LINESTART * FROM FDET ORDER BY RNO DESC;

SUSPEND;

END^



From your application

1. SELECT * FROM GET_FDET(1000,1); ==> You get the first
1000 record;

2. SELECT * FROM GET_FDET(1000,2); ==> You get the second
1000 record;

3. and etc.



with regard,

agung w



[Non-text portions of this message have been removed]