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

Simple Select Single statment doubt : please help

Former Member
0 Likes
492

Dear SAP,

One simple question !!

What happens, If I dont pass all the key values in select single statement.

which data would it bring, the first occurence in DB table ?????

Cont..

And what happens if, I use select single without passing all keys (missing POSNR) but using it in a loop and giving condition as posnr > 900000. does this always bring same values.

Please let me know. Thank you.

Regards

venkat

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
469

Hi

If you don't pass all key fields in SELECT SINGLE there will be multiple records for those condition and it fetches the first record

If you won't pass POSNR in a loop, then for a single doc there will be multiple items and always the first item only selected

if a value exists greater than 900000, then it may consider that value

<b>Reward points for useful Answers</b>

Regards

Anji

5 REPLIES 5
Read only

Former Member
0 Likes
469

SELECT SINGLE only gather one value, so it's the first value it gets from the DB...If you don't specify any key, your going to get the first record of the DB...

In a LOOP is you don't specify the POSNR, your always going to get the same value....

Greetings,

Blag.

Read only

Former Member
0 Likes
470

Hi

If you don't pass all key fields in SELECT SINGLE there will be multiple records for those condition and it fetches the first record

If you won't pass POSNR in a loop, then for a single doc there will be multiple items and always the first item only selected

if a value exists greater than 900000, then it may consider that value

<b>Reward points for useful Answers</b>

Regards

Anji

Read only

Former Member
0 Likes
469

That is not recommened if do not have primary key field then do not use select single.

try to use select up to 1 row instead of select single

Thanks

Seshu

Read only

Former Member
0 Likes
469

Hi Venkat,

It wil behave in the similar way as you thought of.

When you don't have the full key then you should use SELECT...UPTO 1 ROWS ..ENDSELECT as this is much faster in such scenario.

Regards,

Atish

Read only

0 Likes
469

Hi All,

Thanks for your replies !! I am alloting points to all of you.

closing thread !!

Regards

venkat