2007 May 28 6:50 AM
i want to know when to use select single and select upto one row
please urgent what is actual difference please
thanx in advance
2007 May 28 7:01 AM
Hi,
SELECT SINGLE hits the database only once and gets a unique record since we specify all the primary key fields here .. whereas in
SELECT ...UP TO 1 ROWS.. hots the database multiple times and gets all the data into the buffer and then returns the first record from the buffer. Here we do not specify all the primary fields.
Eg:
SELECT carrid
connid
INTO fs_spfli
UP TO 1 ROWS
FROM spfli
WHERE carrid eq 'AA'.
Here the database is hit multiple times and all the records with Carrdi 'AA' are got into the buffer.Then the first entry from the buffer is retirned to the user.
Reward point if useful.
Regards,
Soumya
i want to know when to use select single and select upto one row
please urgent what is actual difference please
thanx in advance
2007 May 28 6:52 AM
Select single - use only when you have primary key in where clause
Select * from table into upto 1 row - if do not have primary key in where clause.
Reward Points if it is helpful
Thanks
Seshu
2007 May 28 6:59 AM
HI,
When you know the primary key well you can use the Select Single.
for eg: MARC table,
we have matnr and werks as primary keys..
If you want to check data from marc based on these two values you can use select single..
select single werks
into (v_asd) from marc
where matnr = <mat> and werks = <werks>.
here when you pass matnr and werks you will find unique combination of both in MARC table..
If you didn't know the primary key in those cases, you can use the Upto 1 rows.
for eg: MARD,
we have matnr , werks amd lgort as primary keys
you want to check for storage location in MARD and you donno the values of remaining primary keys matnr and werks..
select lgort into <v_lgo>
up to 1 rows from mard
where lgort = <lgort>
endselect.
here lgort may be more than one since its a primaty key with matnr and werks,,
so use select upto one rows..
also see this,,..
If we are using SELECT UPTO 1 Row before going to database it is deecided that 1 record is required for output. so it will fetch only first record & come out of execution.
In Select single after selecting records it will decide how many records to need to display.
In performance trace SELECT UPTO 1 ROW is giving good performance.
check with ABAP Examples in SAP.
rewards if useful,
regards,
nazeer
null
2007 May 28 7:01 AM
Hi,
SELECT SINGLE hits the database only once and gets a unique record since we specify all the primary key fields here .. whereas in
SELECT ...UP TO 1 ROWS.. hots the database multiple times and gets all the data into the buffer and then returns the first record from the buffer. Here we do not specify all the primary fields.
Eg:
SELECT carrid
connid
INTO fs_spfli
UP TO 1 ROWS
FROM spfli
WHERE carrid eq 'AA'.
Here the database is hit multiple times and all the records with Carrdi 'AA' are got into the buffer.Then the first entry from the buffer is retirned to the user.
Reward point if useful.
Regards,
Soumya
2007 May 28 7:01 AM
hi,
If you want to get data of a single record use select single.
select up to one row is used in the case we have multiple records depending upon where condition,but we wamt to retrieve only one record we use select up to one row.
selectSINGLE- The result of the selection is a single record . If this record cannot be uniquely identified, the first line of the solution set is selected
2007 May 28 8:29 AM
Hello
here is the difference between select single & select upto n(1) rows:
<b>select single</b>
The result of the selection should be a single entry. If it is not possible to identify a unique entry, the system uses the first line of the selection. For e.g.
that is It fetches single record from the database, based on the condition you specified in the where clause.
DATA : ITAB TYPE ZREKHA_EMP.
SELECT SINGLE *
FROM ZREKHA_EMP
INTO ITAB
WHERE EMPNO = 00101 AND
DEPTNO = 0010.
WRITE : / ITAB-EMPNO, ITAB-EMPNAME .
<b>select upto n rows</b>
Fetches first record if the condition specified in the where clause is satisfied, otherwise it doesn't fetch any record
SELECT field
INTO w_field
FROM table
UP TO 1 ROWS.
ENDSELECT.
I hope it will help u to solve u r query.
Do reward Points
Enjoy
Priyanka
2007 May 28 10:55 AM
Hi Kiron,
1. Without knowing the primary key of the database table you cant use Select single Clause where as you can use select upto 1 row clause .
2. Performance wise Select single will be better than select upto 1 row if you use all primary key fields in the where condition.
3. In into addition the data object may not be an internal table. and appending addition may not be used.
4. Select single is not permitted in Subquries.
2007 May 29 5:03 AM
Hi
Please go through the following link.
http://www.sap-img.com/abap/difference-between-select-single-and-select-upto-one-rows.htm
Hope this will be useful for you.
Regards
Archana