<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                # 在 SAP ABAP 中打開 SQL &本機 SQL > 原文: [https://www.guru99.com/native-open-sql.html](https://www.guru99.com/native-open-sql.html) The goal of this tutorial is not to teach you [SQL](/sql.html) or database concepts but to? introduce you to the SQL diversity in ABAP 在 ABAP / 4 編程語言中,使用兩種類型的 SQL。 1. 原生 SQL 2. OPEN SQL。 Open SQL allows you to access the database tables declared in the ABAP dictionary regardless of the database platform that the R/3 system is using. 本機 SQL 允許您在 ABAP / 4 程序中使用特定于數據庫的 SQL 語句。 這意味著您可以使用不是由 ABAP 詞典管理的數據庫表,因此可以集成不屬于 R / 3 系統的數據。 Open SQL 由一組 ABAP 語句組成,這些語句在 R / 3 系統中的中央數據庫上執行操作。 操作結果和任何錯誤消息均與所使用的數據庫系統無關。 因此,Open SQL 為 SAP 支持的所有數據庫系統提供了統一的語法和語義。 無論使用什么數據庫系統,僅使用 Open SQL 語句的 ABAP 程序都可以在任何 R / 3 系統中工作。 Open SQL 語句只能與在 ABAP 詞典中創建的數據庫表一起使用。 ## 基本的開放式 SQL 命令 * 選擇 * 插 * 更新 * 修改 * 刪除 * 打開光標,關閉光標,關閉光標 Example ``` TABLES SBOOK. DATA C TYPE CURSOR, WA LIKE SBOOK. OPEN CURSOR C FOR SELECT * FROM SBOOK WHERE CARRID = 'LH ' AND CONNID = '0400' AND FLDATE = '19950228' ORDER BY PRIMARY KEY. DO. FETCH NEXT CURSOR C INTO WA. IF SY-SUBRC <> 0. CLOSE CURSOR C. EXIT. ENDIF. WRITE: / WA-BOOKID, WA-CUSTOMID, WA-CUSTTYPE, WA-SMOKER, WA-LUGGWEIGHT, WA-WUNIT, WA-INVOICE. ENDDO. ``` 輸出 1995 年 2 月 28 日漢莎航空 0400 航班的乘客清單: ## **打開 SQL 返回碼** All Open SQL statements fill the following two system fields with return codes. **SY-SUBRC** 在每個 Open SQL 語句之后,如果操作成功,則系統字段 SY-SUBRC 包含值 0,否則返回非 0 的值。 **SY-DBCNT** 在執行 Open SQL 語句后,系統字段 SY-DBCNT 包含已處理的數據庫行數。 ## 本機 SQL As already mentioned, Native SQL allows you to use database-specific SQL statements in an ABAP program. 要使用本機 SQL 語句,必須在其前面加上 EXEC SQL 語句,然后在其后面加上 ENDEXEC 語句。 句法 ``` EXEC SQL [PERFORMING <form>]. <Native SQL statement> ENDEXEC. ``` There is no period after Native SQL statements. Furthermore, using inverted commas (") or an asterisk (*) at the beginning of a line in a native SQL statement does not introduce a comment as it would in normal ABAP syntax. You need to know whether table and field names are case-sensitive in your chosen database. 在本機 SQL 語句中,使用主機變量在數據庫表和 ABAP 程序之間傳輸數據。 它們在 ABAP 程序中聲明,并在本機 SQL 語句中以冒號(:)開頭。 您可以將基本結構用作宿主變量。 例外地,將 INTO 子句中的結構視為其所有字段均單獨列出。 與 Open SQL 中一樣,在 ENDEXEC 語句之后,SY-DBCNT 包含已處理的行數。 在幾乎所有情況下,ENDEXEC 語句后 SY-SUBRC 都包含值 0。 ## 開放式 SQL-性能規則 To improve the performance of the SQL and in turn of the ABAP program, one should take care of the following rules- **保持結果集較小** * 使用 where 子句 * 如果僅需要數據庫中的一條記錄,請盡可能使用 SELECT SINGLE。 **Minimize the Amount of Data Transferred** * 限制行數 * 如果表中僅需要某些字段,請使用 SELECT < field1 > < field2 > INTO ...語句 * 限制列數 * 使用聚合函數 **Minimize the Number of Data Transfers** * 避免嵌套選擇循環 * 另一種選擇是使用 SELECT .. FOR ALL ENTRIES 語句。 與在內部表的 LOOP 期間執行大量 SELECT 或 SELECT SINGLE 語句相比,該語句通常效率更高。 * 使用字典視圖 * 在 FROM 子句中使用聯接 * 在 where 子句中使用子查詢 **Minimize the Search Overhead** * 在 where 子句中使用索引字段 * 訪問數據庫時,請始終確保使用了正確的索引。 **Reduce the Database Load** * 正在緩沖 * 邏輯數據庫 * 避免重復訪問數據庫 **Using Internal Tables to Buffer Records** * 為了避免多次執行相同的 SELECT(因此有重復的選擇),可以使用 HASHED 類型的內部表來提高性能。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看