zoukankan      html  css  js  c++  java
  • Open SQL:5)Open SQL获取数据行数限制

          在数据库SQL查询中当要获取前几条数据时会用到关键字TOP,在Open SQL中也有相类似的功能,可以使用 UP TO n ROWS语法来限制读取数据的条数,语法如下:
         SELECT * INTO ...... UP TO N ROWS.

      [FOR EXAMPLE]

      TABLES:SPFLI.

      DATA: P_SPFLI LIKE STANDARD TABLE OF SPFLI WITH HEADER LINE.
      SELECT FROM SPFLI INTO CORRESPONDING FIELDS OF TABLE P_SPFLI UP TO ROWS.
      LOOP AT P_SPFLI.
        WRITE: / SY-TABIX, ':P_SPFLI-CARRID=',P_SPFLI-CARRID.
      ENDLOOP.

      *执行结果如下截图: 

     

      使用PACKAGE SIZE N连续读取数据。

      [FOR EXAMPLE]
      TABLES:SPFLI.

      DATA:T_SPFLI LIKE STANDARD TABLE OF SPFLI WITH HEADER LINE.
      SELECT FROM SPFLI
      INTO CORRESPONDING FIELDS OF TABLE T_SPFLI
      PACKAGE SIZE UP TO 20 ROWS.  ”UP TO 20 ROWS限制返回20行数据,否则返回所有的数据。
      ULINE.
       LOOP AT T_SPFLI.
        WRITE: / SY-TABIX,':T_SPFLI-CARRID=',T_SPFLI-CARRID,
               / SY-TABIX,':T_SPFLI-CONNID=',T_SPFLI-CONNID,
               / SY-TABIX,':T_SPFLI-AIRPFROM=',T_SPFLI-AIRPFROM,
               / SY-TABIX,':T_SPFLI-AIRPTO=',T_SPFLI-AIRPTO.
       ENDLOOP.
      ENDSELECT.

      *以上执行结果部分截图如下: 

     

  • 相关阅读:
    September 29th 2017 Week 39th Friday
    September 28th 2017 Week 39th Thursday
    September 27th 2017 Week 39th Wednesday
    September 26th 2017 Week 39th Tuesday
    September 25th 2017 Week 39th Monday
    September 24th 2017 Week 39th Sunday
    angular2 学习笔记 ( Form 表单 )
    angular2 学习笔记 ( Component 组件)
    angular2 学习笔记 ( Http 请求)
    angular2 学习笔记 ( Router 路由 )
  • 原文地址:https://www.cnblogs.com/foxting/p/2520283.html
Copyright © 2011-2022 走看看