Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

explained me this select statement...

Former Member
0 Likes
700

Hi all,

What do this select statement:

SELECT * UP TO 1 ROWS FROM LIPS WHERE ZZOBJNR = VA_L_OBJNR.

I have never seen "select * up to 1 rows".

Thanks all.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
684

It will fetch only the first record from table even if more than one records match your selection criteria.

The action is similar to SELECT SINGLE *

Message was edited by: Sudhir Bhate

6 REPLIES 6
Read only

Former Member
0 Likes
685

It will fetch only the first record from table even if more than one records match your selection criteria.

The action is similar to SELECT SINGLE *

Message was edited by: Sudhir Bhate

Read only

Former Member
0 Likes
684

Fabrizio,

This will SELECT only one row from the database even if the where clause is satisfied by multiple rows.

I would rather suggest you to use SELECT single, which gives a better performance.

Regards,

Ravi

Note : Please reward the posts that help you.

Read only

Former Member
0 Likes
684

what ever the record that satisifies the where condition it will fetch, and even if you have more records with that condition it will fetch the first record that satisfies the condition.

vijay

Read only

Former Member
0 Likes
684

Hi

It's way to say to system to get out the first record is found.

You can also write this statament in this way:

SELECT * FROM LIPS WHERE ZZOBJNR = VA_L_OBJNR.

EXIT.

ENDSELECT.

Or

SELECT SINGLE * FROM LIPS WHERE ZZOBJNR = VA_L_OBJNR.

But this last statament is not really correct, because ZZOBJNR is not the key of LIPS.

Max

Read only

Former Member
0 Likes
684

OK, Thanks all....A lot of points for all...

Read only

Former Member
0 Likes
684

Hai Ballante,

Here is the explanation.

... UP TO n ROWS

Effect

This addition restricts the number of rows in the result set. A data object of the Type i is expected for n. A positive number in n indicates the maximum number of rows in the result set. If n contains the value 0, all selected rows are passed to the result set. If n contains a negative number, an exception that cannot be handled is raised.

If the addition ORDER BY is also specified, the rows of the hit list are sorted on the database server and only the number of sorted rows specified in n are passed to the result set. If the addition ORDER BY is not specified, n is filled with any number of rows in the result set that meet the WHERE condition.

with regards,

Manikandan R