Home
Native SQL joins should be used
Rule description
- Native SQL joins should be used
Non-compliant Code Example
BEGIN
FOR order_table IN (SELECT * FROM orders) LOOP
FOR order_items_table IN (SELECT * FROM order_items) LOOP --Non compliant code (Used multiple for loop instead of joins)
DBMS_OUTPUT.PUT_LINE('Order Id: ' || order_table.id || ', Order Amount: ' || order_table.amount || ', Order Items: ' || order_items_table.Quantity);
END LOOP;
END LOOP;
END;
Compliant Code Example
SELECT
od.*, odi.*
FROM
orders od
INNER JOIN order_items odi ON --Compliant code (Used native joins)
odi.order_id = od.order_id
ORDER BY
od.order_date DESC;