10. Retrieving data with select statements Flashcards
SQL
is a language specifically designed for use with relational database systems.
SQL three main components
Data manipulation language (DML), data definition language (DDL) and data control language (DCL)
Data manipulation language
For retrieving and updating information in the database.
Data Definition Language (DDL)
For defining database objects and specifying the structure of the data in the database. In SAP, these functions are handled primarily by the ABAP Dictionary and the Database Utility.
Data Control Language (DCL)
For controlling access to DML and DDL functions
Data Control Language (DCL)
For controlling access to DML and DDL functions.
The DML provides the four basic data operations
- Select (retrieve)
2. Insert
3. Update
4. Delete
Open SQL
Open SQL is a subset of standard SQL with a specific syntax recognised by ABAP.
SELECT STATEMENT
is used to read records from a database table.
Tables statement
Serves two purposes: It declares to the program which ABAP Dictionary tables will be accessed.
and
It creates a work area where individual records from the table can be stored. The work area is an area in memory, just like a program variable, and it is sized so that it can hold exactly one record from the specified table.
WHERE clause
The WHERE clause restricts the records that are retrieved from the database.
SY-SUBRC
is set after each SELECT from the database. If at least one record was found that matched the selection criteria, SY-SUBRC is set to zero. Otherwise, SY-SUBRC is set to a non-zero value
INTO
When selecting individual columns from a database table, an INTO clause is required. Data is not automatically placed into the corresponding fields of the table work area.
INTO CORRESPONDING-FIELDS
The SELECT … INTO CORRESPONDING-FIELDS OF replaces coding the individual fields that the values are selected into from the database table and results in code that is easier to read without any performance losses.