您好我有两个相继执行的select语句。编程语言是ABAP。是否可以合并这两个select语句以减少select语句的数量?
SELECT * FROM (me->db_table)
UP TO mynumber ROWS
INTO CORRESPONDING FIELDS OF TABLE mytable
WHERE x = y
AND n = m
ORDER BY (x).
SELECT * FROM (me->db_table)
UP TO mynumber ROWS
APPENDING CORRESPONDING FIELDS OF TABLE mytable
WHERE x = y
AND n = m
ORDER BY (x).
提前致谢
答案 0 :(得分:3)
这两个语句之间的x或me-> db_table是否有任何变化?如果没有,只需执行
SELECT * FROM (me->db_table)
UP TO mynumber ROWS
INTO CORRESPONDING FIELDS OF TABLE mytable
WHERE x = y
AND n = m
ORDER BY (x).
append lines of mytable to mytable.
我不确定最后一个语句是否会发出语法错误,如果是,请尝试
SELECT * FROM (me->db_table)
UP TO mynumber ROWS
INTO CORRESPONDING FIELDS OF TABLE tmp
WHERE x = y
AND n = m
ORDER BY (x).
append lines of tmp to mytable.
append lines of tmp to mytable.
其中tmp应与mytable具有相同的类型。关键是,两个选项都是相同的,因此结果是,你在mytable中有两次相同的数据。