‎2007 Jan 08 11:28 AM
Hi,
I am using Select Single Statement inside a Loop for Validating , is there any problem regarding Performace.
Loop at itb_file_input into wa_itb_file_input.
......
.......
.......
......
.......
SELECT SINGLE varbl
FROM agr_1252
INTO v_varbl
WHERE agr_name EQ wa_itb_file_input-child
AND varbl EQ wa_itb_file_input-orgname.
.....
....
Endloop.
<i>Thanks .</i>Avi.............
‎2007 Jan 08 11:33 AM
yes..u shud not use any select statment inside a loop as it will increase database hit time ..on each n every loop pass ur porgram will hit databsae and fetch entries..
instead of tht u can use "slect statement with clause "for all entries" in ur internal table and fetch data in one shot and then u can have loop at on tht internal table to process or validate some other conditions..it will enhance performance..
hope it clarifies..
reward if helpfull.
u can press f1 on select statement to learn abt for all entries variant.
amit
‎2007 Jan 08 11:31 AM
hi,
avoid that logic.
try this.
1) select the records into an internal table.
2) inside loop use read the above internal table
3) performance will improve
Regards
Anver
‎2007 Jan 08 11:32 AM
SINGLE or * a SELECT inside a Loop will always adversley affect the Performance.. Use an Itab. sort it & READ itab with Key.. BINARY search for a much improved performance..
~Suresh
‎2007 Jan 08 11:31 AM
Yes, it will give perfromance issues. Instead of selecting one time u r selecting multiple time right.
Better dont use select statement inside loop.
‎2007 Jan 08 11:32 AM
HI,
i think there is no problem...
just clear the field v_varbl after each passs...
Only problem it may lead to is performance....drop
--santhosh
‎2007 Jan 08 11:33 AM
yes..u shud not use any select statment inside a loop as it will increase database hit time ..on each n every loop pass ur porgram will hit databsae and fetch entries..
instead of tht u can use "slect statement with clause "for all entries" in ur internal table and fetch data in one shot and then u can have loop at on tht internal table to process or validate some other conditions..it will enhance performance..
hope it clarifies..
reward if helpfull.
u can press f1 on select statement to learn abt for all entries variant.
amit
‎2007 Jan 08 11:35 AM
hi Avi .. Select query inside a loop always has impact on performance.
You can use
Select varbl INTO i_varbl FROM agr_1252
FOR ALL ENTRIES IN itb_file_input
WHERE agr_name EQ itb_file_input-child
AND varbl EQ itb_file_input-orgname.
i_varbl is an internal table.
‎2007 Jan 08 11:37 AM
Hi,
It is better not to use SELECt within a loop, instead you can do as
SELECT varbl
FROM agr_1252
INTO table i_varbl
FOR ALL ENTRIES IN i_itb_file
WHERE agr_name EQ i_itb_file_input-child
AND varbl EQ i_itb_file_input-orgname.
Loop at itb_file_input into wa_itb_file_input.
......
.......
.......
......
.......
READ TABLE i_itb_file into wa_itb_file
WITH KEY agr_name EQ wa_itb_file_input-child
varbl EQ wa_itb_file_input-orgname.
IF sy-subrc = 0.
v_varbl = wa_itb_file-varbl.
ENDIF.
.....
....
Endloop.Hope you are clear.
Reard poinst and close the thraed if ur problem go solved.