09-10-2007 11:52 AM
Hi All,
What is the use of up to 1 rows in select statement.
for example
SELECT kostl
FROM pa0001
INTO y_lv_kostl UP TO 1 ROWS
WHERE pernr EQ pernr
AND endda GE sy-datum.
ENDSELECT.
I'm unable to get in wat situations we hav to add up to 1 rows
please help me out...
Thanks,
santosh.
09-10-2007 11:59 AM
Up to 1 rows - it gets the single record from the database table based on where condition,normally i use select single if i have proper where condition ,if i do not have where condition ( Primary key) then i will use Select up to 1 rows.
Requiment would be - you have all materials in internal table,then you need to get material description for each material then i will use select up to 1 row or select single ..
Hope you got it
Thanks
Seshu
09-10-2007 11:56 AM
Use "select up to 1 rows" only if you are sure that all the records returned will have the same value for the field(s) you are interested in.
select up to 1 rows may assume that there is no primary key supplied and will try to find most suitable index.
09-10-2007 11:56 AM
Hi Dear,
Select upto One row will improve your performanance when you have to select one row in table inspite of selcting all to know more abt this check in trips and tricks given in sap.
Reward Points if useful
Bohra.
09-10-2007 11:56 AM
Hi,
Use "select up to 1 rows" only if you are sure that all the records returned will have the same value for the field(s) you are interested in. If not, you will be reading only the first record which matches the criteria, but may be the second or the third record has the value you are looking for.
The System test result showed that the variant Single * takes less time than Up to 1 rows as there is an additional level for COUNT STOP KEY for SELECT ENDSELECT UP TO 1 ROWS.
The 'SELECT .... UP TO 1 ROWS' statement is subtly different. The database selects all of the relevant records that are defined by the WHERE clause, applies any aggregate, ordering or grouping functions to them and then returns the first record of the result set.
Regards,
Bhaskar
09-10-2007 11:59 AM
Up to 1 rows - it gets the single record from the database table based on where condition,normally i use select single if i have proper where condition ,if i do not have where condition ( Primary key) then i will use Select up to 1 rows.
Requiment would be - you have all materials in internal table,then you need to get material description for each material then i will use select up to 1 row or select single ..
Hope you got it
Thanks
Seshu