Application Development 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: 

difference between this two select statements

Former Member
0 Kudos

hi. whats the difference between these 2 select statements?

select *

into corresponding fields of table t_rules

from ztf0208a where

catype = t_item-call_type and

oservice = t_item-orig_srvce and

tservice = t_item-term_srvce and

caclass = t_item-call_class and

bukrs = p_bukrs.

*********************************************************************

select * from ztf0208a where

catype = t_item-call_type and

oservice = t_item-orig_srvce and

tservice = t_item-term_srvce and

caclass = t_item-call_class and

zoffset = 'X' and

bukrs ne p_bukrs.

move-corresponding ztf0208a to it_offset.

append it_offset. clear it_offset.

endselect.

4 REPLIES 4

Former Member
0 Kudos

Hi,

Both the selects fetches you the data, but the second select has an performance issue. Since the control passes between database server and application server between every Select..Endselect statement. It is not advisable to use Select..Endselect. The first select is the best one as it fetches all records at once.

Thanks & Regards,

Navneeth K.

former_member181995
Active Contributor
0 Kudos

here is your second query

select * from ztf0208a where
catype = t_item-call_type and
oservice = t_item-orig_srvce and
tservice = t_item-term_srvce and
caclass = t_item-call_class and
zoffset = 'X' and"this condition is one of the difference
bukrs ne p_bukrs."here one more difference which is NE but in above is equales to

Sorry if my answer was insufficient.

peter_ruiz2
Active Contributor
0 Kudos

hi,

this code


select *
into corresponding fields of table t_rules
from ztf0208a where
catype = t_item-call_type and
oservice = t_item-orig_srvce and
tservice = t_item-term_srvce and
caclass = t_item-call_class and
bukrs = p_bukrs.

transfers the extracted data into table t_rules

the second one transfers the extracted data into a work area with the structure ztf0208a and will require you to include ZT0208 in the Tables definition.

the first one runs faster.

regards,

Peter

Former Member
0 Kudos

Hi,

In the first select query you are getting the data into internal table(t_rules) directly,

but in the second select query you are fetching the data first into 'ztf0208a' work area and then moving the data from the work area to internal table.

In first select query database is hit only one time and the internal table is at once with all the data based on where clause

but in second query database will be hit for every row which will be selected based on the Where clause.

so second query is not good in terms of performance.

Regards,

Syed