Bug
Code Rules in Bug category
Category | Severity | Name | Description |
---|---|---|---|
|
|
|
The rule "All branches in a conditional structure should not have exactly the same implementation" states that when writing a PL/SQL code that contains a conditional structure (such as an IF statement), each branch of the conditional structure should have a different implementation. This means that the code should not be written in such a way that all of the branches have the same implementation, as this would be redundant and could lead to inefficient code. This rule helps to ensure that the code is written in an efficient and effective manner. |
|
|
|
The rule "Collections should not be iterated in FOR loops" in PL/SQL code means that collections should not be used in a FOR loop. Instead, collections should be iterated using a cursor, which is a looping construct that allows for the iteration of a collection. This rule is important because it ensures that the code is efficient and that it does not cause any unnecessary performance issues. Additionally, using a cursor allows for more flexibility when iterating over a collection, as it allows for the use of different types of iterators. |
|
|
|
The rule "COMMIT and ROLLBACK should not be called from non-autonomous transaction triggers" states that when writing PL/SQL code, COMMIT and ROLLBACK should not be used in triggers that are not autonomous transactions. Autonomous transactions are transactions that are independent of the current transaction and can be committed or rolled back without affecting the current transaction. Non-autonomous transactions are transactions that are dependent on the current transaction and any changes made to them will affect the current transaction. Therefore, when writing PL/SQL code, it is important to ensure that COMMIT and ROLLBACK are not called from non-autonomous transaction triggers to avoid any unexpected changes to the current transaction. |
|
|
|
The rule "COMMIT should not be used inside a loop" states that the COMMIT statement should not be used inside a loop in PL/SQL code. This is because a COMMIT statement will cause the entire transaction to be committed, and any subsequent changes made within the loop will not be saved. Instead, the COMMIT statement should be used after the loop has been completed, so that all changes are committed at once. |
|
|
|
The rule "Constant declarations should contain initialization assignments" states that when declaring a constant in PL/SQL, it should be initialized with an assignment. This means that when a constant is declared, its value should be set immediately. This ensures that the constant is always initialized with a value and can be used in the code without any unexpected behavior. |
|
|
|
This rule states that constraints should not be applied to data types that cannot be constrained. This is because applying constraints to data types that cannot be constrained will result in an error. For example, if a constraint is applied to a data type such as a BLOB (Binary Large Object) or CLOB (Character Large Object), the constraint will not be enforced and an error will be thrown. Therefore, it is important to ensure that constraints are only applied to data types that can be constrained. |
|
|
|
The DELETE and UPDATE statements should contain a WHERE clause in order to limit the scope of the operation. Without a WHERE clause, the statement will delete or update all rows in a table, which is not usually the desired outcome. The WHERE clause should specify the criteria for the rows to be affected by the statement. This ensures that only the intended rows are affected and that other rows are not unintentionally modified. |
|
|
|
The rule "DML events clauses should not include multiple OF clauses" states that when using Data Manipulation Language (DML) events, only one OF clause should be used. This means that when writing DML events, the syntax should only include one OF clause. Multiple OF clauses can lead to syntax errors and unexpected results, so it is important to adhere to this rule when writing DML events. |
|
|
|
The END LOOP should be followed by a semicolon (;) rule in PL/SQL code states that the END LOOP statement must be followed by a semicolon (;) in order for the code to be valid and executable. This is because the END LOOP statement marks the end of a loop, and the semicolon (;) is used to terminate the statement. Without the semicolon (;), the code will not be valid and will not execute correctly. |
|
|
|
The rule "Explicitly opened cursors should be closed" states that any cursors that have been explicitly opened in a PL/SQL block must be closed before the block is exited. This is important because it ensures that any resources associated with the cursor are released and that the cursor is no longer available for use. Failure to close an explicitly opened cursor can lead to unexpected behavior and errors when the block is executed. It is also important to note that cursors that are opened implicitly (i.e. not explicitly opened) do not need to be closed. |
|
|
|
The FETCH ... BULK COLLECT INTO code rule states that the FETCH ... BULK COLLECT INTO statement should not be used without a LIMIT clause. This is because the FETCH ... BULK COLLECT INTO statement can be used to retrieve a large number of rows from a database table, and without a LIMIT clause, it could retrieve an excessive amount of data, which could cause performance issues. Therefore, it is important to always include a LIMIT clause when using the FETCH ... BULK COLLECT INTO statement to ensure that only the necessary amount of data is retrieved. |
|
|
|
The FORALL statement in PL/SQL is used to execute a set of DML statements in a single call, and can improve performance when used correctly. The SAVE EXCEPTIONS clause should be used when using the FORALL statement to ensure that any exceptions encountered during the execution of the DML statements are saved and can be inspected later. This clause allows the user to identify which statements failed and why, and can be used to take corrective action if necessary. |
|
|
|
The rule "FORMS_DDL('COMMIT') and FORMS_DDL('ROLLBACK') should not be used" states that the PL/SQL code should not use the FORMS_DDL('COMMIT') and FORMS_DDL('ROLLBACK') commands. These commands are used to commit or rollback changes to the database, and should not be used in PL/SQL code as they can cause unexpected results. Instead, the code should use the COMMIT and ROLLBACK commands, which are more reliable and provide better control over the database transactions. |
|
|
|
The Pl_Sql code rule that "Functions should end with RETURN statements" states that all functions should be terminated with a RETURN statement. This RETURN statement should be the last line of code in the function and should return a valid value that is compatible with the function's return type. This ensures that the function returns the expected result and does not cause any unexpected errors. |
|
|
|
The Pl_Sql code rule "Identical expressions should not be used on both sides of a binary operator" states that when writing code, the same expression should not be used on both sides of a binary operator. This is because the expression on the left side of the operator will be evaluated first, and then the expression on the right side will be evaluated. If the same expression is used on both sides, the result of the evaluation will always be the same, and the code will not produce the desired result. This rule helps to ensure that code is written correctly and produces the desired results. |
|
|
|
The IF statement condition should not evaluate unconditionally to TRUE or FALSE rule states that when writing an IF statement, the condition should not be written in a way that it will always evaluate to either TRUE or FALSE. This means that the condition should be written in a way that it can evaluate to either TRUE or FALSE depending on the data that is being evaluated. This is important in order to ensure that the IF statement will be able to evaluate the data accurately and provide the correct output. |
|
|
|
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. |
|
|
|
The rule "Individual WHERE clause conditions should not be unconditionally true or false" states that each condition in a WHERE clause should be evaluated and not be predetermined as either true or false. This means that each condition should be checked against the data and not be assumed to be true or false without any evaluation. This helps to ensure that the results of the query are accurate and that the query is not returning incorrect results due to an assumption that a condition is true or false. |
|
|
|
The "Insert statement values not including Non-Null Columns" rule in PL/SQL states that when inserting values into a table, any non-null columns must be included in the insert statement. This means that any columns with a non-null constraint must be included in the insert statement, even if the value being inserted is NULL. If a non-null column is not included in the insert statement, an error will be thrown. This rule is important to ensure data integrity and accuracy in the database. |
|
|
|
The "Jump Statements Should Not Be Followed by Dead Code" rule states that when a jump statement (such as a GOTO, EXIT, or RETURN statement) is used, the code that follows should not be executed. This is because the jump statement will cause the program to jump to a different part of the code, and any code after the jump statement will not be executed. This can lead to unexpected results and can be difficult to debug. Therefore, it is best practice to avoid having dead code after a jump statement. |
|
|
|
The "Loops with at most one iteration should be refactored" rule for PL/SQL code states that any loops that contain only one iteration should be replaced with simpler code. This is because loops are designed to execute a set of instructions multiple times, and a loop with only one iteration is redundant and can be replaced with simpler code. Refactoring loops with only one iteration can help improve code readability and maintainability, as well as reduce the amount of code needed to achieve the same result. |
|
|
|
The rule "MLSLABEL should not be used" states that the PL/SQL code should not use the MLSLABEL keyword. This keyword is used to identify a label in the source code, which can be used to control the flow of the program. Instead, other methods such as IF-THEN-ELSE or CASE statements should be used to control the flow of the program. Using MLSLABEL can lead to unexpected results and should be avoided. |
|
|
|
The NCHAR and NVARCHAR2 size in bytes rule states that the size of NCHAR and NVARCHAR2 data types must be specified in bytes rather than characters. The maximum size of an NCHAR or NVARCHAR2 column is 2000 bytes. The number of characters that can be stored in an NCHAR or NVARCHAR2 column is dependent on the number of bytes specified for the column. For example, if the size of the column is specified as 10 bytes, then the maximum number of characters that can be stored in the column is 10 characters. |
|
|
|
The rule "NULL should not be compared directly" in PL/SQL code means that when comparing two values, the comparison should not be done directly with the NULL value. Instead, the IS NULL or IS NOT NULL operators should be used. This is because the comparison of two NULL values will always return NULL, which may not be the desired result. Using the IS NULL or IS NOT NULL operators will ensure that the comparison is done correctly and that the expected result is returned. |
|
|
|
The rule "Nullable subqueries should not be used in NOT IN conditions" states that when using a NOT IN condition in a PL/SQL statement, the subquery should not return any null values. This is because when a subquery returns a null value, the NOT IN condition will always evaluate to false, even if the value being compared is not in the subquery. This can lead to unexpected results and should be avoided. |
|
|
|
The rule "Output parameters should be assigned" states that when writing PL/SQL code, any output parameters should be assigned a value before the code is executed. This ensures that the output parameters are set to the correct value and will be returned correctly when the code is executed. This is important for code readability and maintainability, as it allows the programmer to clearly see what values are being returned from the code. It also helps to prevent unexpected results, as any output parameters that are not assigned a value will return a NULL value. |
|
|
|
The "Overridden Predefined Exceptions" rule in PL/SQL code states that when a predefined exception is raised, the associated error code and error message should be overridden with a user-defined error code and message. This allows for more precise control over the error handling process, as well as providing more meaningful error messages to the user. This rule also states that the user-defined error code should be unique, and should be used consistently throughout the code. Additionally, the user-defined error message should provide more information about the cause of the error, and should be written in a language that is easily understood by the user. |
|
|
|
The rule "PACKAGE BODY initialization sections should not contain RETURN statements" states that the initialization sections of a PL/SQL package body should not contain RETURN statements. This rule is important because RETURN statements are used to terminate a PL/SQL program, and having them in the initialization sections of a package body could lead to unexpected behavior. Additionally, RETURN statements should only be used when necessary, as they can be difficult to debug. |
|
|
|
The rule states that when writing PL/SQL code for a pipelined function, the function must contain at least one PIPE ROW statement and should not return an expression. A PIPE ROW statement is used to return a row from a pipelined function, and an expression is a statement that evaluates to a single value. This rule ensures that the pipelined function is able to return multiple rows, as opposed to just a single value. |
|
|
|
The rule "Positional and named arguments should not be mixed in invocations" states that when invoking a PL/SQL procedure or function, all arguments should either be passed in using their position in the argument list, or all arguments should be passed in using their named parameters. Mixing positional and named arguments in the same invocation is not allowed. |
|
|
|
The RAISE_APPLICATION_ERROR code rule states that the RAISE_APPLICATION_ERROR command should only be used with error codes that range from -20,000 to -20,999. This command is used to raise an exception and return an error message to the user. The error message should be meaningful and provide information about the cause of the error. This code rule ensures that the error codes used are specific and meaningful, so that the user can easily understand the cause of the error. |
|
|
|
The rule related to IF / ELSIF statements and WHEN clauses in a CASE states that they should not have the same condition. This means that the conditions used to evaluate the IF / ELSIF statements and WHEN clauses should be distinct from each other. This ensures that the CASE statement is properly evaluated and that the correct result is returned. Having the same condition for both the IF / ELSIF statements and WHEN clauses can lead to unexpected results and should be avoided. |
|
|
|
The rule "ROWNUM should not be used at the same query level as ORDER BY" states that the ROWNUM pseudo-column should not be used in the same query as the ORDER BY clause. This is because the ROWNUM pseudo-column is assigned to each row before the ORDER BY clause is applied, so the results of the query may not be consistent. Therefore, it is recommended to use the ORDER BY clause before the ROWNUM pseudo-column is applied. |
|
|
|
The Pl_Sql code rule "Scale should not be specified for float types" means that when defining a float type in Pl_Sql, the scale (the number of digits after the decimal point) should not be specified. This is because float types are designed to store numbers with a variable number of digits after the decimal point, and specifying a scale would limit the number of digits that can be stored. |
|
|
|
When declaring string variables with no size specification, the maximum size of the string is determined by the database. The maximum size of the string will depend on the database's configuration and the data type of the string. The maximum size of the string can be determined by querying the database for the maximum length of the data type. For example, if the string is of type VARCHAR2, the maximum size of the string can be determined by querying the database for the maximum length of VARCHAR2. |
|
|
|
This rule states that when using PL/SQL code, strings should only be stored in variables or columns that are large enough to contain them. This is important to ensure that the data is not truncated and that the code runs correctly. It is also important to consider the size of the string when allocating memory for the variable or column, as this can affect performance. |
|
|
|
The SYNCHRONIZE rule states that the SYNCHRONIZE keyword should not be used in PL/SQL code. This keyword is used to ensure that all transactions are synchronized with the database, and can cause performance issues if used incorrectly. To avoid this, developers should use other methods to ensure that transactions are properly synchronized with the database. This could include using the COMMIT command, or using the DBMS_LOCK package. |
|
|
|
A syntax error in PL/SQL code occurs when the code does not follow the rules of the PL/SQL language. This type of error can be caused by incorrect spelling, incorrect punctuation, incorrect capitalization, or incorrect use of reserved words. Syntax errors can prevent the code from being executed, and can cause the code to produce unexpected results. In order to avoid syntax errors, it is important to read and understand the PL/SQL language and to follow the rules of the language when writing code. |
|
|
|
The rule states that the number of variables in a FETCH statement should match the number of columns in the cursor. This means that when a FETCH statement is used to retrieve data from a cursor, the number of variables used to store the data must be equal to the number of columns in the cursor. This ensures that all the data in the cursor is retrieved and stored in the correct variables. Failure to do so may result in data loss or incorrect data retrieval. |
|
|
|
The result_cache hint should be avoided as it can lead to unexpected results and performance issues. This hint is used to force the query optimizer to cache the result set of a query, which can lead to incorrect results if the underlying data has changed since the query was executed. Additionally, the result set can become stale if the underlying data is updated, leading to performance issues. Therefore, it is recommended to avoid using the result_cache hint and instead use other methods such as materialized views to improve query performance. |
|
|
|
The rule "Unary prefix operators should not be repeated" states that when using unary prefix operators in PL/SQL code, the same operator should not be used multiple times in succession. For example, if the operator is "-", then "- -" should not be used. This is because the double operator would be redundant and could lead to confusion. Additionally, it could lead to errors in the code. Therefore, it is best practice to only use unary prefix operators once in succession. |
|
|
|
The Uninitialized NOT NULL Variables rule states that all NOT NULL variables must be initialized before use. This rule ensures that all variables are properly initialized and that the code does not attempt to use a variable that has not been initialized. This rule helps to prevent errors and unexpected behavior in the code. It also helps to ensure that the code is more readable and maintainable. |
|
|
|
Unsupported Syntax Errors are errors that occur when a PL/SQL code contains syntax that is not supported by the version of the PL/SQL compiler being used. These errors are usually caused by using a feature that is not available in the version of the compiler being used. Examples of unsupported syntax errors include using a feature that was introduced in a later version of the compiler, or using a feature that has been deprecated in the current version of the compiler. |
|
|
|
The rule "VARCHAR2 and NVARCHAR2 should be used" states that the VARCHAR2 and NVARCHAR2 data types should be used when creating columns in a database table. These data types are used to store character strings, and are the preferred data types for storing character strings in Oracle databases. VARCHAR2 is used for storing strings of up to 4000 characters, while NVARCHAR2 is used for storing strings of up to 2000 characters. Both data types are used for storing character strings, but NVARCHAR2 should be used when the data is Unicode-encoded, as it is more efficient than VARCHAR2 for storing Unicode-encoded data. |
|
|
|
The rule "Variables and columns should not be self-assigned" in PL/SQL code means that variables and columns should not be assigned to themselves. This is a best practice to follow in order to avoid errors and confusion. Self-assigning variables and columns can lead to unexpected results, and can be difficult to debug. It is best to assign variables and columns to other values or results from other operations. |
|
|
|
When using PL/SQL code, it is important to remember that variables declared multiple times in nested scope will override the original declaration. This means that if a variable is declared in an outer scope and then again in a nested scope, the nested declaration will take precedence. This can lead to unexpected results if the programmer is not aware of the precedence rules. It is important to ensure that variables are only declared once in a given scope to avoid any potential issues. |
|
|
|
The rule "WHERE clause conditions should not be contradictory" states that when writing a WHERE clause in a PL/SQL statement, the conditions should not contradict each other. This means that the conditions should not be mutually exclusive, as this will cause the statement to return an empty result set. For example, the following statement would not be valid: WHERE x = 1 AND x = 2. This statement is contradictory because it is impossible for x to be both 1 and 2 at the same time. |