LizaPaul
asked on
retrieve fixed records from Interbase
I am using Interbase 6. I want to extract data from an Interbase table using a SELECT statement, but i would like to restrict the number of records extracted to 100. How do I go about doing this with an SQL statement. Or is there any other way to get on with this.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you for the answer, it has helped me.
this version orders the records properly, inside of the loop. ( assuming that EMP_NO is the correct order )
CREATE PROCEDURE GET_NEXT_RECORDS (
ASTART_NUM INTEGER,
ARETURN_COUNT INTEGER)
RETURNS (
EMP_NO INTEGER,
FULL_NAME VARCHAR (50))
AS
declare variable nCount INTEGER;
BEGIN
/* Initialize counter */
nCount = 0;
/* loop over select statement of ordered rows*/
FOR SELECT EMP_NO, full_name FROM EMPLOYEE
where (EMP_NO > :ASTART_NUM )
order by EMP_NO
into :EMP_NO, :FULL_NAME DO begin
/* check counter against desired amount */
if (nCount < :AReturn_Count ) then begin
/* retun a row and increment counter */
SUSPEND;
nCount = nCount + 1;
end
else
/* AReturn_count has been met, terminate */
Exit;
end
END