Home
Improper constraint forms should not be used
Description
The rule "Improper constraint forms should not be used" states that any PL/SQL code should not use any forms of constraints that are not supported by the language. This includes using constraints that are not supported by the language, such as using a non-standard syntax or using an unsupported type of constraint. This rule is important to ensure that the code is written correctly and is not prone to errors or unexpected behavior. Additionally, it helps to ensure that the code is compatible with other PL/SQL code and databases.
Key Benefits
- Ensures Data Integrity: Proper constraints ensure that data is entered correctly and consistently, preventing data entry errors and ensuring data integrity.
- Reduces Complexity: By limiting the data that can be entered into a database, constraints reduce the complexity of the data and make it easier to query.
- Improves Performance: Constraints can help improve the performance of queries by limiting the amount of data that needs to be processed.
Non-compliant Code Example
<<outerloop>> BEGIN DECLARE abc INTEGER RANGE 0..15; --Non compliant code (Improper constraint is used) xyz NUMBER RANGE 0..25; --Non compliant code (Improper constraint is used) BEGIN IF xyz = outerloop.abc THEN NULL; END IF; END; END;
Compliant Code Example
<<outerloop>> BEGIN DECLARE abc INTEGER; --Compliant code xyz NUMBER; --Compliant code BEGIN IF xyz = outerloop.abc THEN NULL; END IF; END; END;