Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 2069

Re: SELECT SINGLE VS SELECT UP TO 1 ROWS

$
0
0

Pradeep,

 

Performance wise you would not find much difference.

 

Question is WHEN you should use either of them?

 

SELECT SINGLE MATNR WERKS MMSTA

FROM MARC INTO ( LV_MATNR, LV_WERKS, LV_MMSTA )

WHERE MATNR IN S_MATNR

     AND WERKS IN S_WERKS.

 

 

SELECT MATNR WERKS MMSTA UP TO 1 ROWS

FROM MARC INTO LWA_MARC

WHERE WERKS IN S_WERKS

      AND MMSTA = 'Z1'.


If your requirement is to fetch just one row (either for validation or for some other purpose) and you can provide complete PRIMARY KEYS (ie MATNR and WERKS) of the table in the WHERE clause, you should use SELECT SINGLE.


If you cannot provide the complete PRIMARY KEYS in the WHERE clause, but you just want one entry from table, then you should use SELECT UP TO 1 ROWS because, partial primary keys or no primary keys in WHERE clause could pull multiple rows from table, but you want to restrict it to just 1 row.


Hope this clarifies. You can see similar answer here.

When to use SELECT SINGLE and SELECT UP TO 1 ROWs in actual project? – SAP Yard


Regards,

Raju.

.


Viewing all articles
Browse latest Browse all 2069

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>