[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index]
[Date Index]
[Thread Index]
[SQR-USERS Info]
[SQRUG Home Page]
Re: Sybase - Selecting specific numbers of records
- Subject: Re: Sybase - Selecting specific numbers of records
- From: "Dray, Adam" <Adam.Dray@PHH.COM>
- Date: Tue, 26 Oct 1999 14:36:35 -0400
Others have replied to this, but I'd like to add my two cents.
This is precisely the place where Exit-Select is useful. To grab rows
10-15 inclusive, you might do something like this:
Move 10 to #min_row
Move 15 to #max_row
Move 0 to #current_row
Begin-Select
SOMECOLUMNS
Add 1 to #current_row
If #current_row >= #min_row
Do Some_Procedure ! or just process the rows here
! Else do nothing
End-If
If #current_row > #max_row
Exit-Select ! stop fetching rows from the database
End-If
>From SOMETABLE
Order By SOMECOLUMN ! required to guarantee row order
Truthfully, I suspect that you probably don't mean to do this.
Perhaps the table has a key on it that you can use to limit your
query to the rows you really want. Take a look at the possibility
of adding a good Where clause to the select statement.
> -----Original Message-----
> From: Carlton Conley [SMTP:cconley@CDG-INC.COM]
> Sent: Tuesday, October 26, 1999 2:07 PM
> To: Multiple recipients of list SQR-USERS
> Subject: Re: Sybase - Selecting specific numbers of records
>
> Not knowing why you want only 20 rows makes it somewhat difficult, are
> there
> 10 rows specically you want or just any ten rows.
>
> if the later you so something like:
>
>
> if #count <= 10
> do someprocedure
> end-if
>
> begin-procedure someprocedure
> begin-select
>
> SOMECOLUMN(S)
>
> add 1 to #count
>
> FROM SOMETABLE
>
> end-select
> end-procedure
>
> > -----Original Message-----
> > From: Discussion of SQR, SQRIBE Technologies's database reporting
> > language [mailto:SQR-USERS@list.iex.net]On Behalf Of Khaled Abdel-Rahman
> > Sent: Tuesday, October 26, 1999 11:22 AM
> > To: Multiple recipients of list SQR-USERS
> > Subject: Sybase - Selecting specific numbers of records
> >
> >
> > Hi,
> > This is my first question to the list an the following is my first
> > question!!!!!
> >
> > Suppose you have a table which has 20 rows, I want to get only rows
> > from 10-15. How can I don that?!
> >
> > Thanks in advance,
> > Best Regards,
> > Khaled
> >