CRITICAL
Rule Definition
Having an SQL query inside a loop is usually the source of performance and scalability problems especially if the number of iterations become very high (for example if it is dependent on the data returned from the database).
This iterative pattern has proved to be very dangerous for application performance and scalability. Database servers handle in a much better set-oriented pattern rather than pure iterative ones.
Remediation
Try to reduce the number of opening cursors in the loops.
Violation Code Sample
[BEGIN of a LOOP (see what all type of loop are possible in Language Reference )]
open CAST_TEST
with #sql{
select A,B, C, D
from CAST1_JOINT T1
WHERE
M = :N AND
ORDER BY
1 ASC
WITH UR
}
into A, B, C, D
for CAST2_JOINT;
[END of a LOOP (see what all type of loop are possible in Language Reference )]
Reference
Standard suggestions based on CAST Quality Model
Related Technologies
Technical Criterion
CWE-1050 - Excessive Platform Resource Consumption within a Loop
About CAST Appmarq
CAST Appmarq is by far the biggest repository of data about real IT systems. It's built on thousands of analyzed applications, made of 35 different technologies, by over 300 business organizations across major verticals. It provides IT Leaders with factual key analytics to let them know if their applications are on track.