Frage

Hello I have two select statements that are executed right after each other. The programming language is ABAP. Is it possible to merge those two select statements in order to reduce the amount of select statements?

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). 

Thanks in advance

War es hilfreich?

Lösung

Is there any change to x or me->db_table between those two statements? If not, simply do

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.

I'm not sure if the last statement issues a syntax error, if so, try

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.

where tmp should have the same type as mytable. The point is, that both selects are identical, therefore the result is, that you'll have the same data in mytable twice.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top