ABAP SELECT statement basics

  SQL

OverView

Here I would like to touch upon the basics of the SQL SELECT clause.
First of all, please refer to the sample code.

Sample Code

Explanation

1. gets multiple records, but when you get 1 record by UP TO 1 ROWS option
SQL ends. Therefore, this is the SQL used when you want to retrieve only one record.

2. is the SQL to get only one record. For the difference between the SINGLE option and the UP TO 1 ROWS option
There are various discussions, but when searching by specifying the primary key, use the SINGLE option, otherwise use the UP TO 1 ROWS option.
The personal view is to use it.

3. is used when one record is acquired and then some processing is performed and the next processing is performed.
However, it is effective when the number of records is small, but performance is deteriorated when the number of records is tens of thousands, so it is not recommended to use it.

4. is SQL that stores the fetched records in an internal table. I think it will be used most.

5. is the SQL when specifying multiple items to be acquired. When fetching multiple items, parentheses () are required after the INTO clause.

LEAVE A COMMENT