Q
Problem solve Get help with specific problems with your technologies, process and projects.

Which SQL command is better?

Which of the following SQL commands is better to use SELECT SINGLE * or SELECT SINGLE INTO?
Specifying the fields you are using is usually better programming practice. The simplest reason is that the fewer fields retrieved, the better the performance.

On a more philosophical level, some developers say the former is better, because then if you, or a later developer...

needs a field, it is available. I disagree. In my view, the developer should always know what data he is dealing with, and should only specify that which he is actually using. To do otherwise, can lead to unexpected results. For example, a table with two fields whose names are very similar. E.g. txtln and txtnl. Perhaps you are only interested in txtln, and you define only that in your DATA statements, and specify the field in your SELECT. If you accidentally type txtnl, you will get a syntax error. However, if you use SELECT SINGLE *, you won't know, until your program starts behaving oddly. Many SAP field names are abbreviations of German words. Many are very similar to each other. This kind of error does happen!

The only times I would use SELECT SINGLE * are:

1. If I really do need all the fields
2. I need many fields from the table, and the danger of un-clear coding is greater than that of specifying unused fields.
3. You need the structure to work with SAP defined structures -- e.g. when using SAP function modules.

This was last published in November 2004

Dig Deeper on SAP Basis administration and NetWeaver administration

PRO+

Content

Find more PRO+ content and other member only offers, here.

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchManufacturingERP

SearchOracle

SearchDataManagement

SearchAWS

SearchBusinessAnalytics

SearchCRM

SearchContentManagement

SearchFinancialApplications

Close