cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

select rows start at a specified index using OPEN SQL

0 Likes
2,907

Hi all,

If I want to select 1st~100th entries in database, OPEN SQL has a term 'UP TO 100 ROWS' to do it.

But I can not find a quickly way to select 100th~200th entries in database. Is there any method in open SQL, to let me select  entries start at a specified index?

I need to support this features in SAP GATEWAY backend. Hope someone can tell me how to do it, thanks.

Regards

Dongqiang

View Entire Topic
Chintu6august
Contributor
0 Likes

Hi,

you can write your query like this :

SELECT * FROM <database table> 

INTO |APPENDING/CORRESPONDING FIELDS OF TABLE <itab >

PACKAGE SIZE 100.

ENDSELECT.

it will give you entries in the form of package, append them to new internal table as per your requirement.

thanks!!

0 Likes

Hi Chintu,

Thanks for replying!

When I want to get 100th~200th entries, I didn't want to get 1st~100th entries. Using package size is still started at 1st entries, would it cause a performance issue when I only want to get 100000th~100100th entries in database?

Chintu6august
Contributor
0 Likes

I don't think you can write such select statement, where you can specify index 100 to 200.

you can make use of LOOP AT <itab> FROM <index1> TO <index2> for multiple records based on index

or for single record

READ STATEMENT <itab> INDEX  which will allow you to access record of particular index.

thanks!!

0 Likes

I was confused.

FIORI APP send such a request to GATEWAY, seems this is based on FIORI design guideline. But how can I provide such data from the backend?

Since the database table is very large, maybe I have to loop table on package size, and using internal table to get such data.

matt
Active Contributor

There is no concept of order in a relational database table. When you select up to 100 rows, you may get a different set the first time you run it from the second time. So your request doesn't really make sense.

Why would you want the "second 100 entries?" when that is simply not defined? In a relational database the phrase "second 100 entries" has no meaning - it doesn't exist.

If you need to pull records off 100 at a time (which is the usual scenario), then the answer has been given by Chintu Adi's first reply.

On that basis, and to prevent further point hunters repeating the same (or adding new, bad information), I'm locking the thread.