ABAP database operation series (2)

Source: Internet
Author: User

Continue to explain our database operation statements:

1. Select details:
Select single: This statement selects a piece of data from the database. If you can obtain multiple pieces of data based on the query condition (where), there must be (endselect). In this case, there will be a warning (slin) in the abap syntax check, so we should try to avoid using it. You can use this instead:
Select XXX from XXX into XXX.
Exit.
Endselect.
That is to say, the premise of using this is to use the table's primary key for queries.
Select distinct: duplicate records are filtered out. Because the use of distinct will lead to a sorting operation on the database server, affecting performance, it is better to implement it in ABAP.
Select XXX from XXX into itab Where xxx.
Sort itab by XXX.
Delete adjacent duplicates from itab comparing XXX.
Select single for update: When this is used, it can prevent other transactions from updating or modifying the field, which is generally not used.
Select *: select all defined fields in the database table. If not all fields are required, avoid using this option, which may affect the performance. It is best to specify the fields you need.
Select S1 S2... SN: Specify the field you want to select.
Note: If the selected field contains the data type: string or rawstring, it cannot be used.
Select (source_text ):
A. source_text is a field. You can define a struct variable and assign the name of the field you want to select to this variable.
Data: field (10) Type C. Field = "carrid ".
Select (field) from XXX ...........

B. source_text is a string. That is to say, if you want to select multiple fields, you can add the fields concatenate to the string, and then separated by space.
Data: Rochelle S (100) type C.
Data: l_carrid like SPFLI-CARRID,
Rochelle connid like SPFLI-CONNID.
Concatenate 'carrid' connid' into l_s separated by space.
Select (l_s)
From spfli
Into (l_carrid, l_connid)
Where xxx.
Endselect.

C. source_text is an internal table. You can select one or more fields.
Data: ftab type table of string.
Append 'cityfrom' to ftab.
Append 'city' to ftab.
Select (ftab)
From spfli into XXX Where xxx.
Endselect.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.