‎2007 Nov 19 5:58 AM
SELECT * FROM SFLIGHT INTO SFLIGHT_WA
WHERE SEATSOCC < SFLIGHT~SEATSMAX
AND EXISTS ( SELECT * FROM SPFLI
WHERE CARRID = SFLIGHT~CARRID
AND CONNID = SFLIGHT~CONNID
AND CITYFROM = 'FRANKFURT'
AND CITYTO = 'NEW YORK' )
AND FLDATE BETWEEN '19990101' AND '19990331'.
ENDSELECT.
plzzz advise when do you use EXISTS how is it more efficient to FOR ALL ENTRIES
‎2007 Nov 19 10:50 AM
If you use a subquery with the EXISTS operator, the expression is true if the subquery selects at least one line. You can use * in the SELECT clause of subqueries that use EXISTS.
<b>
For all entries.</b>
... FOR ALL ENTRIES IN itab WHERE cond
Effect
SELECT ... FOR ALL ENTRIES IN itab WHERE cond returns the union of the solution sets of all SELECT statements that would result if you wrote a separate statement for each line of the internal table. Duplicates are discarded from the result set. <b><u>If the internal table itab does not contain any entries, the system treats the statement as though there were no WHERE cond condition, and selects all records</u></b> (in the current client).
i hope this will suffice.
even if there are no records in for all entries the select statements fetches values.
But this is not the case with exists.
‎2007 Nov 19 6:08 AM
HI,
effect of exists:
The condition is met for a table entry if the result set of the subquery subquery contains [does not contain] any lines.
it is for data dictionary tables
for all entries is for checking the record in internal table is existing or not.
rgds,
bharat.
‎2007 Nov 19 6:21 AM
" if the result set of the subquery subquery contains [does not contain] any lines. "
Can you please elaborate
‎2007 Nov 19 10:50 AM
If you use a subquery with the EXISTS operator, the expression is true if the subquery selects at least one line. You can use * in the SELECT clause of subqueries that use EXISTS.
<b>
For all entries.</b>
... FOR ALL ENTRIES IN itab WHERE cond
Effect
SELECT ... FOR ALL ENTRIES IN itab WHERE cond returns the union of the solution sets of all SELECT statements that would result if you wrote a separate statement for each line of the internal table. Duplicates are discarded from the result set. <b><u>If the internal table itab does not contain any entries, the system treats the statement as though there were no WHERE cond condition, and selects all records</u></b> (in the current client).
i hope this will suffice.
even if there are no records in for all entries the select statements fetches values.
But this is not the case with exists.