Subject | Re: [IBDI] function TOP n FROM... was (Porting from...) |
---|---|
Author | Helen Borrie |
Post date | 2000-06-25T13:36:29Z |
Ooops, left a spare bit of "first thought" code in there:
___________________________________________________
"Ask not what your free, open-source database can do for you,
but what you can do for your free, open-source database."
(J.F.K.)
>create procedure TOP_N(n integer, LastID integer)http://www.interbase2000.org
>returning (sFirstName varchar(30), sLastName varchar(30), dBirthday date)
>as
>declare variable iCounter integer;
>declare variable bOK char(1);
>declare variable bOKtoGo char(1);
>begin
>iCounter = 0;
>bOK = 'F';
>bOKtoGo = 'F';
>for select FirstName, LastName, Birthday from GuestBook
>/* ****where dBirthday > :StartingValue**** */ /* tho' you could range it
>if appropriate */
>order by Birthday /* indexed */
>into :sFirstName, :sLastName, :dBirthday do
>begin
> if (Not (bOK='T')) then
> if GuestBook.ID = :LastID then bOK='T'; /* the final row from the
>previous set */
> if (bOKtoGo='T') then
> begin
> suspend;
> iCounter = :iCounter + 1;
> if iCounter = :n then Exit;
> end
> if bOK='T' then bOKtoGo='T'; /* we have gone past the last row of the
>previous set */
>end
>
>This sample really just demonstrates how to get Top(n) from a certain
>starting point in an ordered dataset. Top(n) isn't necessarily going to be
>the best way to go for a web interface. If you have a stateful web
>application, like WebHub, you can probably economise on database i/o by
>holding your dataset on the web server and using the methods of your web
>application to control which records to display. InternetXpress (Delphi
>5), while not stateful, gives you a data provider layer where you can
>control which rows go out in response to an http request.
>
>Helen
>http://www.interbase2000.org
>___________________________________________________
>"Ask not what your free, open-source database can do for you,
>but what you can do for your free, open-source database."
>(J.F.K.)
>
>------------------------------------------------------------------------
>IT Professionals: Match your unique skills with the best IT projects at
>http://click.egroups.com/1/3381/5/_/679568/_/961939954/
>------------------------------------------------------------------------
>
>Community email addresses:
> Post message: IBDI@onelist.com
> Subscribe: IBDI-subscribe@onelist.com
> Unsubscribe: IBDI-unsubscribe@onelist.com
> List owner: IBDI-owner@onelist.com
>
>Shortcut URL to this page:
> http://www.onelist.com/community/IBDI
___________________________________________________
"Ask not what your free, open-source database can do for you,
but what you can do for your free, open-source database."
(J.F.K.)