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

select statement

Former Member
0 Likes
657

Below statement how many records will fetch from bsad table?is it total records of Bseg table & single record of Bseg table.

SELECT SINGLE * FROM BSAD WHERE AUGBL = I_BSEG-AUGBL

AND BELNR NE I_BSEG-BELNR

AND BELNR NE I_BSEG-AUGBL.

6 REPLIES 6
Read only

Former Member
0 Likes
630

SELECT SINGLE * will select only single record from that table,

Why did u get that doubt??

SELECT SINGLE will always select only 1 record,

SELECT SINGLE * will also select only one record but all the fields will be selected

Read only

Former Member
0 Likes
630

Hi Vishnu,

Select SINGLE always gets only 1 record .

Reward If Useful,

Regards,

Chitra

Read only

Former Member
0 Likes
630

Hi Vishnu,

Your select statement will extract only ONE record from BSAD table, based on the where condition of BSEG values.

Which means Select Single * will get only one record at a time. Here 'Single' denotes one record and '*' denotes all the fields of the table BSAD.

Hope this helps.

Thanks,

Srinivasa

Read only

Former Member
0 Likes
630

It will get either 0 or 1 record depending on whether or not the condition in the WHERE is met. (But performance will be an issue. There is probably a simpler way to do this. What do you need to do?)

Rob

Read only

Former Member
0 Likes
630

hi,

you will get only one row of all the colums for the given condition.

SELECT SINGLE * always fetch only one row whereas SELECT SINGLE <field>

fetch only one value for that particular field.

Thanks,

Senthil kumar

Read only

Former Member
0 Likes
630

As Rob says, no records from BSEG (there's no select from BSEG) and either 1 or 0 from BSAD... I'd guess 1 because the 2 "NE" should be satisified by zillions of entries. My concern mirror Rob's comments - a select statement like

SELECT SINGLE * FROM BSAD WHERE AUGBL = I_BSEG-AUGBL
AND BELNR NE I_BSEG-BELNR
AND BELNR NE I_BSEG-AUGBL.

has the ability to bring your database to its knees - unless you have added some local indexes it will do a slow table scan. When accessing BSAD, always try to specify as many elements of the key as possible... if you have just retrieve a BSEG record (as indicated from the "I_BSEG" code) then use the KUNNR from that row to start with, and then the other BSAD fields. At least then your database may only have a few hundred / thousand rows to process.

Jonathan