Major
Code Rules in Major Severity
Category | Severity | Name | Description |
---|---|---|---|
Bug | Major | All branches in a conditional structure should not have exactly the same implementation |
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. |
Maintainability | Major | CASE should be used rather than DECODE |
The CASE statement in PL/SQL is used to select one of several blocks of statements based on a given condition. It is similar to the DECODE statement, but it is more powerful and more flexible. The CASE statement can be used to replace multiple DECODE statements, making the code more readable and efficient. The CASE statement can also be used to evaluate multiple conditions and execute different statements based on the result. |
Maintainability | Major | CASE structures should not have too many WHEN clauses |
The rule "CASE structures should not have too many WHEN clauses" states that when using a CASE structure in PL/SQL code, it is best practice to limit the number of WHEN clauses used. This is because too many WHEN clauses can lead to code that is difficult to read and maintain, and can also lead to performance issues. It is recommended to use IF-THEN-ELSE statements instead of multiple WHEN clauses when possible. |
Maintainability | Major | Collapsible if statements should be merged |
The "Collapsible if statements should be merged" rule states that when two or more if statements can be logically combined into one, they should be merged into a single statement. This helps to reduce the complexity of the code and improve readability. By merging multiple if statements, the code becomes more concise and easier to understand. Additionally, it can help to reduce the number of lines of code and make debugging and maintenance easier. |
Maintainability | Major | Column aliases should be defined using AS |
The rule "Column aliases should be defined using AS" in PL/SQL code states that when creating a column alias, the keyword "AS" should be used. This is done to make the code easier to read and understand. For example, if you wanted to create an alias for a column called "FirstName" in a table called "Employees", you would write the following code: SELECT FirstName AS "Employee Name" FROM Employees; By using the keyword "AS", it is easier to distinguish between the original column name and the alias. This rule is important to follow when writing PL/SQL code, as it helps to make the code more readable and understandable. |
Maintainability | Major | Column names should be used in a SQL ORDER BY clause |
The Pl_Sql code rule that "Column names should be used in a SQL ORDER BY clause" states that when writing a SQL query, the column names should be explicitly specified in the ORDER BY clause. This ensures that the query is written correctly and that the results are ordered in the desired way. This rule also helps to avoid any unexpected behavior when the query is executed. |
Maintainability | Major | Columns should be aliased |
The "Columns should be aliased" rule in PL/SQL code states that when selecting multiple columns from a table, each column should be given an alias. This is done to make the code easier to read and understand. By assigning an alias to each column, it is easier to identify which column is being referenced in the code. This also helps to avoid confusion when referencing columns in other parts of the code. Additionally, it is best practice to use meaningful aliases that accurately describe the column. |
Maintainability | Major | Columns to be read with a SELECT statement should be clearly defined |
The "Columns to be read with a SELECT statement should be clearly defined" rule states that when writing a SELECT statement in PL/SQL, the columns that will be read from the database should be explicitly stated. This ensures that the query is only retrieving the necessary data, and that the results of the query are predictable. It also helps to prevent errors and improve the performance of the query. |
Maintainability | Major | Compound triggers should define at least two triggers |
Compound triggers are a type of trigger in PL/SQL that allow multiple triggers to be defined for a single table. The rule states that compound triggers should define at least two triggers. This means that when a compound trigger is created, it must include two or more triggers that will be triggered when a certain event occurs. This allows for more complex logic to be implemented when a certain event occurs, such as updating multiple tables or performing multiple operations. Compound triggers can be used to simplify and streamline the code needed to perform complex operations when a certain event occurs. |
Maintainability | Major | CREATE_TIMER should not be used |
The CREATE_TIMER code rule states that the CREATE_TIMER command should not be used. This command is used to create a timer in a PL/SQL block, which is an action that can cause performance issues and should be avoided. Instead, the DBMS_SCHEDULER package should be used to create and manage timers. |
Maintainability | Major | CROSS JOIN queries should not be used |
The rule CROSS JOIN queries should not be used is a rule of thumb for PL/SQL code. It means that when writing a query, one should avoid using the CROSS JOIN operator. This operator is used to combine every row from one table with every row from another table, resulting in a Cartesian product. This can lead to a large number of unnecessary rows being returned, which can lead to performance issues. It is generally better to use other operators such as INNER JOIN or LEFT JOIN, which can be used to limit the number of rows returned. |
Maintainability | Major | Dead stores should be removed |
The rule "Dead stores should be removed" states that any variables that are assigned a value but never used should be removed from the PL/SQL code. This is because any variables that are never used waste memory and can slow down the code execution. Removing these variables can help to improve the performance of the code. Additionally, it can help to reduce the complexity of the code and make it easier to read and understand. |
Maintainability | Major | Deprecated LONG and LONG RAW datatypes should no longer be used |
The rule "Deprecated LONG and LONG RAW datatypes should no longer be used" states that the LONG and LONG RAW datatypes, which are deprecated, should not be used in PL/SQL code. These datatypes have been superseded by other datatypes, such as CLOB and BLOB, which are more efficient and provide better performance. Therefore, it is recommended that developers use the newer datatypes instead of the deprecated LONG and LONG RAW datatypes. |
Bug | Major | DML events clauses should not include multiple OF clauses |
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. |
Maintainability | Major | END statements of labeled blocks should be labeled |
The "END statements of labeled blocks should be labeled" rule states that any END statement used to close a labeled block should be labeled with the same label used to open the block. This helps to ensure that the code is properly structured and that the programmer can easily identify the start and end of the labeled block. Labeling the END statement also helps to reduce the chances of errors in the code, as it makes it easier to identify the start and end of the block. |
Maintainability | Major | END statements of labeled loops should be labeled |
The END statements of labeled loops should be labeled rule states that when a loop is labeled, the corresponding END statement should also be labeled. This is important for readability and maintainability of the code, as it makes it easier to identify which loop a particular END statement belongs to. It also helps to ensure that the loop is properly closed, as any errors in the loop's structure can be easily identified. This rule is applicable to all types of loops, including FOR, WHILE, and REPEAT loops. |
Maintainability | Major | EXECUTE IMMEDIATE should be used instead of DBMS_SQL procedure calls |
The EXECUTE IMMEDIATE should be used instead of DBMS_SQL procedure calls rule states that when executing dynamic SQL statements, the EXECUTE IMMEDIATE statement should be used instead of the DBMS_SQL package. EXECUTE IMMEDIATE is a PL/SQL statement that can be used to execute dynamic SQL statements. It is more efficient than the DBMS_SQL package, which requires more code and is less secure. This rule helps to ensure that dynamic SQL statements are executed in a secure and efficient manner. |
Maintainability | Major | EXIT WHEN should be used rather than IF ... THEN EXIT; END IF |
The EXIT WHEN code rule states that the EXIT statement should be used instead of IF ... THEN EXIT; END IF when exiting a loop. This is because the EXIT WHEN statement is more concise and easier to read than the IF ... THEN EXIT; END IF syntax. Additionally, the EXIT WHEN statement is more efficient as it does not require the PL/SQL engine to evaluate the condition before exiting the loop. |
Maintainability | Major | Features deprecated in Oracle 12 should not be used |
The rule "Features deprecated in Oracle 12 should not be used" means that any features that have been deprecated (or removed) in Oracle 12 should not be used in PL/SQL code. This includes any features that have been removed from Oracle 12 or any features that have been marked as deprecated, which means they may be removed in a future version. This rule is important to follow as deprecated features may not work correctly in newer versions of Oracle, and may cause unexpected errors or performance issues. |
Maintainability | Major | FETCH ... BULK COLLECT INTO should be used |
The FETCH ... BULK COLLECT INTO rule states that when retrieving data from a database, the FETCH statement should be used in conjunction with the BULK COLLECT INTO clause. This allows for the retrieval of multiple rows of data in a single operation, which can improve performance and reduce the amount of coding needed. The BULK COLLECT INTO clause allows for the retrieval of data into a collection of records, which can then be looped through and processed. This rule is especially useful when dealing with large datasets, as it can significantly reduce the amount of time needed to process the data. |
Maintainability | Major | Files should not have too many lines of code |
The Pl_Sql code rule that "Files should not have too many lines of code" is an important rule to follow when writing code. This rule helps to ensure that code is easy to read and understand, as well as maintain and debug. Too many lines of code can make it difficult to find and fix errors, as well as make the code more difficult to read. This rule encourages developers to break up their code into smaller, more manageable chunks, which can make it easier to read and debug. |
Maintainability | Major | FOR loop end conditions should not be hard - coded |
The rule "FOR loop end conditions should not be hard-coded" means that the end conditions for a FOR loop should not be explicitly stated in the code. Instead, the end conditions should be determined by the data or variables that are being used in the loop. This ensures that the loop will always terminate when the conditions are met, regardless of the data or variables used. This also makes the code more flexible and easier to maintain. |
Maintainability | Major | FORALL should be used |
The FORALL statement in PL/SQL is used to execute a set of DML statements (INSERT, UPDATE, DELETE) on a collection of data. It is much more efficient than using a loop to execute the same set of DML statements on each element of the collection. The FORALL statement is used to improve the performance of a PL/SQL block by reducing the number of context switches between the PL/SQL engine and the SQL engine. When using the FORALL statement, it is important to remember that the same DML statement is executed on all elements of the collection. This means that the same set of values is used for each element of the collection, and that the same set of conditions is applied to each element. This can be a great advantage when dealing with large collections of data, as it reduces the amount of code required to process the data. Therefore, the rule for using the FORALL statement is to use it whenever possible to improve the performance of a PL/SQL block. It is especially useful when dealing with large collections of data, as it reduces the amount of code required to process the data. |
Maintainability | Major | FULL OUTER JOINS should be used with caution |
The rule "FULL OUTER JOINS should be used with caution" in PL/SQL code means that when using a FULL OUTER JOIN, one should be aware of potential performance issues and other complications. FULL OUTER JOINS are used to combine the results of two or more tables, but they can be computationally expensive and can produce unexpected results if not used correctly. Therefore, it is important to understand the implications of using a FULL OUTER JOIN and to use it only when necessary. |
Maintainability | Major | Function and procedure names should comply with a naming convention |
This rule states that all function and procedure names should follow a specific naming convention. This naming convention should be consistent and easy to understand, and should include information about the purpose of the function or procedure. This will help to ensure that all functions and procedures are easily identifiable and can be quickly located. Additionally, this will help to reduce the chances of naming conflicts between different functions and procedures. |
Maintainability | Major | Function and procedure parameters should comply with a naming convention |
The rule "Function and procedure parameters should comply with a naming convention" states that all parameters used in functions and procedures should be named according to a specific convention. This helps to make the code more readable and easier to understand. It also helps to avoid naming conflicts between parameters and other objects in the database. The naming convention should be consistent across all functions and procedures in the database. This ensures that all parameters are easily identifiable and that the code is more maintainable. |
Maintainability | Major | Functions and procedures should not have too many parameters |
The rule "Functions and procedures should not have too many parameters" is an important one to follow when writing PL/SQL code. Having too many parameters can make the code difficult to read and maintain, and can lead to errors. It is best to limit the number of parameters to only the ones that are absolutely necessary. Additionally, it is important to ensure that all parameters are properly documented so that other developers can understand their purpose and use. Finally, it is important to ensure that all parameters are properly validated to ensure that the code is secure and reliable. Following these guidelines will help ensure that your PL/SQL code is well-structured and maintainable. |
Maintainability | Major | FUNCTIONS should not have OUT parameters |
The rule that "FUNCTIONS should not have OUT parameters" means that functions should not have parameters that are used to send data out of the function. This is because functions are used to return a single value, and OUT parameters are used to send multiple values. If a function is used to return multiple values, it should be written as a procedure instead. This rule helps to ensure that functions are used for their intended purpose and that procedures are used for more complex operations. |
Maintainability | Major | GOTO should not be used within loops |
The GOTO statement should not be used within loops in PL/SQL code. This is because it can cause unexpected behavior and can make the code difficult to read and maintain. Instead, use the EXIT statement to exit the loop, or use the CONTINUE statement to skip the rest of the loop and continue with the next iteration. This will help to ensure that the code is more readable and maintainable. |
Maintainability | Major | GOTO statements should not be used |
The GOTO statements should not be used rule in PL/SQL code states that the GOTO statement should not be used to control the flow of a program. This statement can lead to code that is difficult to read and maintain, and can cause unexpected results. Instead, PL/SQL code should use IF-THEN-ELSE, CASE, and LOOP statements to control the flow of a program. |
Maintainability | Major | GROUP BY should not be used in SQL SELECT statements |
The rule "GROUP BY should not be used in SQL SELECT statements" states that the GROUP BY clause should not be used when writing SQL SELECT statements. This rule is applicable to all SQL dialects, including PL/SQL. The GROUP BY clause is used to group rows into sets of summary rows by values of columns or expressions. When used in SELECT statements, the GROUP BY clause can lead to unexpected results and should be avoided. Instead, the ORDER BY clause should be used to sort the results of the query. |
Bug | Major | Identical expressions should not be used on both sides of a binary operator |
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. |
Bug | Major | IF statement conditions should not evaluate unconditionally to TRUE or to FALSE |
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. |
Maintainability | Major | IF statements should not be nested too deeply |
The rule "IF statements should not be nested too deeply" in PL/SQL code means that when writing code, the programmer should avoid nesting multiple IF statements within each other. This is because deep nesting of IF statements can make the code difficult to read and understand, and can also lead to unexpected results. It is generally recommended that IF statements should not be nested more than three levels deep. |
Maintainability | Major | In labeled loops EXIT should exit the label |
The Pl/SQL code rule "In labeled loops EXIT should exit the label" states that when using labeled loops, the EXIT statement should be used to exit the loop with the specified label. This ensures that the loop is exited at the correct point, and that any code after the loop is not executed. This rule helps to ensure that the code is written correctly and that the program runs as expected. |
Bug | Major | Jump statements should not be followed by dead code |
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. |
Maintainability | Major | Labels redefined in inner scopes |
The "Labels redefined in inner scopes" rule in PL/SQL states that labels defined in an outer scope cannot be redefined in an inner scope. This means that if a label is defined in an outer scope, it cannot be used again in an inner scope. This rule is important to ensure that labels are used consistently throughout a PL/SQL program. It also helps to avoid confusion when debugging and troubleshooting code. |
Maintainability | Major | Large item lists should not be used with IN clauses |
The rule "Large item lists should not be used with IN clauses" in PL/SQL code states that when using the IN clause in a SQL statement, it is best to avoid using large item lists as this can lead to performance issues. This is because the IN clause will cause the database to scan through the entire list of items, which can be time consuming if the list is large. It is better to use other clauses such as EXISTS or JOIN to achieve the same result. |
Maintainability | Major | LIKE clauses should not start with wildcard characters |
The rule "LIKE clauses should not start with wildcard characters" in PL/SQL code states that when using the LIKE operator in a query, the search pattern should not begin with a wildcard character. This is because starting a LIKE clause with a wildcard character can cause the query to take a long time to execute as the database engine must search through all possible matches before returning the result. Additionally, starting a LIKE clause with a wildcard character can lead to incorrect results if the search pattern is not well defined. Therefore, it is best practice to avoid beginning LIKE clauses with wildcard characters in PL/SQL code. |
Bug | Major | Loops with at most one iteration should be refactored |
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. |
Maintainability | Major | Magic numbers should not be used |
The "Magic numbers should not be used" rule in PL/SQL code states that hard-coded numeric values should not be used in code. Instead, constants should be used to represent the numeric values, so that the code is more readable and maintainable. This makes it easier to understand the code and to modify it if needed. |
Bug | Major | MLSLABEL should not be used |
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. |
Maintainability | Major | Native SQL joins should be used |
The rule "Native SQL joins should be used" states that when writing PL/SQL code, native SQL joins should be used instead of PL/SQL constructs such as loops and cursors. Native SQL joins are more efficient and can improve the performance of the code. Additionally, using native SQL joins can help to make the code more readable and maintainable. |
Maintainability | Major | NATURAL JOIN queries should not be used |
The rule "NATURAL JOIN queries should not be used" states that when writing PL/SQL code, the use of NATURAL JOIN queries should be avoided. NATURAL JOIN queries are a type of SQL query that combines two or more tables by matching all columns with the same name. This type of query can lead to unexpected results and should be avoided in favor of explicit JOIN queries that specify the columns to be joined. |
Maintainability | Major | Nested blocks should be labeled |
The "Nested blocks should be labeled" rule states that when writing PL/SQL code, all nested blocks should be labeled with a unique identifier. This helps to make the code more readable and easier to debug. Labels should be descriptive and should include the type of block (e.g. IF, LOOP, etc.) as well as the purpose of the block. Labels should be placed at the beginning of the block and should be followed by a colon. This rule helps to ensure that the code is easier to understand and maintain. |
Maintainability | Major | Nested loops should be labeled |
The rule "Nested loops should be labeled" states that when writing PL/SQL code, each loop should be labeled with a unique identifier. This helps to easily identify and debug the loop when necessary. Labeling nested loops also helps to improve the readability of the code, making it easier to understand and maintain. |
Maintainability | Major | Nested subqueries should be avoided |
The rule "Nested subqueries should be avoided" states that when writing PL/SQL code, nested subqueries should be avoided whenever possible. Nested subqueries are subqueries that are nested within other subqueries, and can lead to complex and inefficient code. Instead, it is recommended to use joins or correlated subqueries to achieve the same result with simpler and more efficient code. |
Bug | Major | NULL should not be compared directly |
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. |
Maintainability | Major | NUMBER variables should be declared with precision |
The rule "NUMBER variables should be declared with precision" states that when declaring a NUMBER variable in PL/SQL, the precision should be specified. This means that the total number of digits and the number of digits to the right of the decimal point should be specified. This helps to ensure that the variable can store the desired value without any loss of precision. |
Bug | Major | Output parameters should be assigned |
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. |
Bug | Major | PACKAGE BODY initialization sections should not contain RETURN statements |
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. |
Maintainability | Major | Procedures and functions should be encapsulated in packages |
Encapsulating procedures and functions in packages is a best practice in PL/SQL programming. By doing so, you can group related procedures and functions together, and make them easier to find and maintain. It also allows you to control access to the procedures and functions, and to control the order in which they are loaded into memory. Additionally, it allows you to create global variables that can be used across multiple procedures and functions. Packages also help to improve performance, since all the related code is loaded into memory at once, rather than having to be loaded each time it is used. |
Maintainability | Major | Procedures should have parameters |
The rule that "Procedures should have parameters" states that when creating a procedure in PL/SQL, it should include parameters. Parameters are variables that are passed to the procedure when it is called. They can be used to provide input to the procedure, and they can also be used to return values from the procedure. By using parameters, a procedure can be more flexible and reusable. It can be used in different contexts and can be called with different values. This makes it easier to maintain and debug, and it also makes it easier to use the procedure in different applications. |
Maintainability | Major | Queries should not SELECT too many columns |
The Pl_Sql code rule "Queries should not SELECT too many columns" states that when writing SQL queries, it is best to only select the columns that are necessary for the query. Selecting too many columns can lead to performance issues, as the query will take longer to execute. Additionally, selecting too many columns can lead to confusion and make it difficult to interpret the results. It is best to only select the columns that are necessary for the query, and avoid selecting any unnecessary columns. |
Maintainability | Major | Redundant pairs of parentheses should be removed |
This rule states that any redundant pairs of parentheses should be removed from PL/SQL code. This is to ensure that the code is written in a concise and clear manner, and to reduce the amount of unnecessary characters in the code. Redundant parentheses can be identified by looking for pairs of parentheses that are not necessary for the code to be syntactically correct. By removing these pairs of parentheses, the code will be easier to read and understand. |
Bug | Major | Related IF / ELSIF statements and WHEN clauses in a CASE should not have the same condition |
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. |
Maintainability | Major | RESULT_CACHE should not be used |
The RESULT_CACHE rule states that the RESULT_CACHE hint should not be used in PL/SQL code. This is because the RESULT_CACHE hint can cause unexpected performance issues, and can lead to incorrect results. The RESULT_CACHE hint should only be used in very specific cases, and should be tested thoroughly before being used in production code. |
Maintainability | Major | ROWID and UROWID data types should not be used |
The rule "ROWID and UROWID data types should not be used" states that the ROWID and UROWID data types should not be used in PL/SQL code. These data types are used to store the physical address of a row in a database table, and are not intended to be used in PL/SQL code. Using these data types can lead to unexpected results, and should be avoided. |
Bug | Major | ROWNUM should not be used at the same query level as ORDER BY |
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. |
Maintainability | Major | SIMPLE_INTEGER should be used instead of PLS_INTEGER |
The rule "SIMPLE_INTEGER should be used instead of PLS_INTEGER" states that the SIMPLE_INTEGER data type should be used instead of the PLS_INTEGER data type when declaring variables in PL/SQL code. SIMPLE_INTEGER is a 32-bit signed integer data type, while PLS_INTEGER is a 64-bit signed integer data type. Using SIMPLE_INTEGER instead of PLS_INTEGER will result in more efficient code, as SIMPLE_INTEGER is a smaller data type and requires less memory. Additionally, SIMPLE_INTEGER is more portable, as it is supported by all Oracle databases. |
Maintainability | Major | SQL EXISTS subqueries should not be used |
The rule "SQL EXISTS subqueries should not be used" states that the SQL EXISTS subquery should not be used in a query. EXISTS subqueries are used to check if a certain condition is met in a table. They are usually used to check if a certain record exists in a table. However, using EXISTS subqueries can lead to performance issues and should be avoided. Instead, other methods such as joins should be used to check if a certain record exists in a table. |
Maintainability | Major | SQL statements should not join too many tables |
The rule "SQL statements should not join too many tables" states that SQL statements should be kept simple and should not join more than a few tables. This rule is important to follow because joining too many tables can lead to slower query performance, and can make the SQL statement more difficult to read and understand. Additionally, it can lead to data integrity issues if the tables are not properly joined. It is best to limit the number of tables joined in a single SQL statement to ensure that the query is efficient and the data is accurate. |
Maintainability | Major | Statements should be on separate lines | The Pl_Sql code rule "Statements should be on separate lines" states that each individual statement within a Pl_Sql code block should be on its own line. This helps to improve readability and makes it easier to debug any errors that may occur. It also helps to make the code more organized and easier to maintain. |
Bug | Major | Strings should only be moved to variables or columns which are large enough to hold them |
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. |
Maintainability | Major | Tables should be aliased |
When writing PL/SQL code, it is good practice to alias tables in order to make the code more readable and easier to maintain. Aliasing a table is done by assigning a shorter name to a table, which is then used in the code instead of the full table name. This makes the code more concise and easier to read, as well as easier to maintain if the table name changes in the future. Aliasing tables is also useful when joining multiple tables, as it can help to avoid confusion when referencing columns from multiple tables. |
Bug | Major | The result_cache hint should be avoided |
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. |
Maintainability | Major | TO_DATE and TO_TIMESTAMP should be used with a datetime format model |
The TO_DATE and TO_TIMESTAMP code rules state that when using these functions, a datetime format model should be used. This ensures that the data is stored in the correct format and that the correct information is retrieved from the database. The datetime format model provides a standard way of representing dates and times, which helps to ensure accuracy and consistency across the application. It also helps to prevent errors that can occur when data is stored in an incorrect format. |
Maintainability | Major | TO_NUMBER should be used with a format model | The TO_NUMBER function should be used with a format model when converting a character string to a number. The format model is a template that specifies how the character string should be parsed and converted into a number. It consists of one or more format elements, which are separated by commas. Each format element specifies how a portion of the character string should be converted into a number. |
Maintainability | Major | Track breaches of an XPath rule | The XPath rule is a set of rules that are used to define the structure and content of an XML document. The XPath rule is used to track any breaches of the rule, such as incorrect syntax, missing elements, or incorrect values. The PL/SQL code rule is used to detect any violations of the XPath rule and alert the user. This code rule can be used to ensure that the XML document is valid and conforms to the XPath rule. The PL/SQL code rule can also be used to validate the data in the XML document, ensuring that it is accurate and up-to-date. This code rule can be used to detect any errors or inconsistencies in the XML document and alert the user. |
Maintainability | Major | Track comments matching a regular expression | The Pl_Sql code rule "Track comments matching a regular expression" is used to identify and track comments in a program that match a given regular expression. This rule can be used to identify and track comments that contain specific keywords or phrases, or to identify and track comments that follow a specific pattern. This rule can be used to ensure that comments are consistent and adhere to a specific coding standard. |
Maintainability | Major | Track uses of FIXME tags | The PL/SQL code rule "Track uses of FIXME tags" is used to track the use of FIXME tags in PL/SQL code. FIXME tags are used to indicate areas of code that require attention or further investigation. This rule will help to identify any code that contains FIXME tags, so that they can be addressed quickly and efficiently. This rule will also help to ensure that any code that contains FIXME tags is properly documented and maintained. |
Maintainability | Major | Track uses of NOSONAR comments | The Pl_Sql code rule "Track uses of NOSONAR comments" is used to track the use of NOSONAR comments in a program. NOSONAR comments are used to indicate that a particular piece of code should not be analyzed by a static code analysis tool. This rule helps to ensure that code is properly analyzed and that any potential issues are identified. |
Maintainability | Major | Two branches in a conditional structure should not have exactly the same implementation |
The PL/SQL code rule "Two branches in a conditional structure should not have exactly the same implementation" states that when using a conditional structure such as an IF/ELSE statement, the two branches should not contain the same code. This means that the code should differ in some way, either in the code itself or in the outcome. This rule helps ensure that the code is more robust and that any unexpected behavior can be easily identified and corrected. |
Bug | Major | Unary prefix operators should not be repeated |
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. |
Maintainability | Major | UNION should be used with caution |
The rule "UNION should be used with caution" in PL/SQL code means that when using the UNION operator, developers should be aware of the potential side effects. This is because UNION combines the results of two or more SELECT statements into a single result set, and can cause unexpected results if not used correctly. Developers should ensure that the columns being combined are compatible, and that the data types of the columns being combined are the same. Additionally, developers should be aware of the potential for duplicate records when using UNION, and should use the UNION ALL operator to prevent this from happening. |
Maintainability | Major | Unused labels should be removed |
The rule of "Unused Labels should be removed" in PL/SQL code states that any labels that are not used in the code should be removed. This is important because unused labels can lead to confusion and can make the code difficult to read and understand. Additionally, having too many labels can slow down the performance of the code. Therefore, it is important to ensure that all unused labels are removed from the code to improve readability and performance. |
Maintainability | Major | Unused Procedure and Function Parameters |
The Unused Procedure and Function Parameters rule checks for unused parameters in stored procedures and functions. This rule helps to identify and eliminate unnecessary parameters that can lead to code bloat and confusion. Unused parameters can also lead to potential security vulnerabilities if they are not properly handled. The rule checks for parameters that are declared but not used in the body of the procedure or function. If any unused parameters are found, the rule will generate a warning. |
Bug | Major | VARCHAR2 and NVARCHAR2 should be used |
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. |
Maintainability | Major | VARCHAR2 should be used |
The rule "VARCHAR2 should be used" states that the VARCHAR2 data type should be used when creating variables, columns, and parameters in PL/SQL code. VARCHAR2 is a data type that stores variable-length character strings up to 4000 characters in length. It is the preferred data type for storing character strings in PL/SQL code, as it is more efficient than the CHAR data type and can be used to store strings of varying lengths. Using VARCHAR2 instead of CHAR can help reduce the amount of memory used and improve the performance of the code. |
Bug | Major | Variables and columns should not be self-assigned |
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. |
Maintainability | Major | Variables should be nullable |
The Pl_Sql code rule "Variables should be nullable" states that variables should be declared with the NULL keyword, allowing them to accept a NULL value. This is important because it allows the variable to accept a NULL value without generating an error. This is especially useful when dealing with database operations, as it allows for the possibility of missing or unknown values. This rule also helps to ensure that the code is more robust and can handle unexpected data. |
Maintainability | Major | WHEN clauses should not have too many lines |
The rule "WHEN clauses should not have too many lines" states that when writing PL/SQL code, the WHEN clauses should be kept as concise as possible. This means that the code should be written in such a way that the WHEN clauses are not too long or complex, as this can make the code difficult to read and understand. It is recommended that the WHEN clauses should be kept to a maximum of three lines, and that any complex logic should be broken up into smaller, more manageable chunks. This will help to ensure that the code is easier to read and understand, and that any potential errors can be quickly identified and resolved. |
Bug | Major | WHERE clause conditions should not be contradictory |
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. |