SonarSource Rules
  • Products

    In-IDE

    Code Quality and Security in your IDE with SonarQube Ide

    IDE extension that lets you fix coding issues before they exist!

    Discover SonarQube for IDE

    SaaS

    Code Quality and Security in the cloud with SonarQube Cloud

    Setup is effortless and analysis is automatic for most languages

    Discover SonarQube Cloud

    Self-Hosted

    Code Quality and Security Self-Hosted with SonarQube Server

    Fast, accurate analysis; enterprise scalability

    Discover SonarQube Server
  • SecretsSecrets
  • ABAPABAP
  • AnsibleAnsible
  • ApexApex
  • AzureResourceManagerAzureResourceManager
  • CC
  • C#C#
  • C++C++
  • CloudFormationCloudFormation
  • COBOLCOBOL
  • CSSCSS
  • DartDart
  • DockerDocker
  • FlexFlex
  • GitHub ActionsGitHub Actions
  • GoGo
  • GroovyGroovy
  • HTMLHTML
  • JavaJava
  • JavaScriptJavaScript
  • JSONJSON
  • JCLJCL
  • KotlinKotlin
  • KubernetesKubernetes
  • Objective CObjective C
  • PHPPHP
  • PL/IPL/I
  • PL/SQLPL/SQL
  • PythonPython
  • RPGRPG
  • RubyRuby
  • RustRust
  • ScalaScala
  • ShellShell
  • SwiftSwift
  • TerraformTerraform
  • TextText
  • TypeScriptTypeScript
  • T-SQLT-SQL
  • VB.NETVB.NET
  • VB6VB6
  • XMLXML
  • YAMLYAML
PL/SQL

PL/SQL static code analysis

Unique rules to find Bugs, Vulnerabilities, Security Hotspots, and Code Smells in your PL/SQL code

  • All rules 189
  • Vulnerability4
  • Bug45
  • Security Hotspot2
  • Code Smell138
 
Tags
    Impact
      Clean code attribute
        1. "SYNCHRONIZE" should not be used

           Bug
        2. "FORMS_DDL('COMMIT')" and "FORMS_DDL('ROLLBACK')" should not be used

           Bug
        3. Output parameters should be assigned

           Bug
        4. "ROWNUM" should not be used at the same query level as "ORDER BY"

           Bug
        5. All branches in a conditional structure should not have exactly the same implementation

           Bug
        6. Strings should only be moved to variables or columns which are large enough to hold them

           Bug
        7. "COMMIT" should not be used inside a loop

           Bug
        8. Individual "WHERE" clause conditions should not be unconditionally true or false

           Bug
        9. Nullable subqueries should not be used in "NOT IN" conditions

           Bug
        10. "WHERE" clause conditions should not be contradictory

           Bug
        11. Inserts should include values for non-null columns

           Bug
        12. Unary prefix operators should not be repeated

           Bug
        13. Variables should be declared only once in a scope

           Bug
        14. DML events clauses should not include multiple "OF" clauses

           Bug
        15. "COMMIT" and "ROLLBACK" should not be called from non-autonomous transaction triggers

           Bug
        16. Size should be specified for string variables

           Bug
        17. "PACKAGE BODY" initialization sections should not contain "RETURN" statements

           Bug
        18. Positional and named arguments should not be mixed in invocations

           Bug
        19. Predefined exceptions should not be overridden

           Bug
        20. "NULL" should not be compared directly

           Bug
        21. "NOT NULL" variables should be initialized

           Bug
        22. "NCHAR" and "NVARCHAR2" size should not be specified in bytes

           Bug
        23. "MLSLABEL" should not be used

           Bug
        24. "END LOOP" should be followed by a semicolon

           Bug
        25. Constraints should not be applied to types that cannot be constrained

           Bug
        26. Improper constraint forms should not be used

           Bug
        27. Functions should end with "RETURN" statements

           Bug
        28. Collections should not be iterated in "FOR" loops

           Bug
        29. Scale should not be specified for float types

           Bug
        30. Constant declarations should contain initialization assignments

           Bug
        31. "VARCHAR2" and "NVARCHAR2" should be used

           Bug
        32. "RAISE_APPLICATION_ERROR" should only be used with error codes from -20,000 to -20,999

           Bug
        33. "FETCH ... BULK COLLECT INTO" should not be used without a "LIMIT" clause

           Bug
        34. Anchored types should not be constrained

           Bug
        35. Related "IF/ELSIF" statements and "WHEN" clauses in a "CASE" should not have the same condition

           Bug
        36. Identical expressions should not be used on both sides of a binary operator

           Bug
        37. All code should be reachable

           Bug
        38. Loops with at most one iteration should be refactored

           Bug
        39. Variables and columns should not be self-assigned

           Bug
        40. "DELETE" and "UPDATE" statements should contain "WHERE" clauses

           Bug
        41. Explicitly opened cursors should be closed

           Bug
        42. "IF" statement conditions should not evaluate unconditionally to "TRUE" or to "FALSE"

           Bug
        43. "FORALL" statements should use the "SAVE EXCEPTIONS" clause

           Bug
        44. The "result_cache" hint should be avoided

           Bug
        45. Pipelined functions should have at least one "PIPE ROW" statement and not return an expression (PLS-00633)

           Bug

        Predefined exceptions should not be overridden

        Bug

          Why is this an issue?

          Naming custom exceptions the same as predefined ones, while technically acceptable, is not a good practice.

          Noncompliant code example

          SET SERVEROUTPUT ON
          
          DECLARE
            no_data_found EXCEPTION; -- Noncompliant, overrides an Oracle predefined exception
          
            d VARCHAR2(1);
          BEGIN
            SELECT dummy INTO d FROM DUAL WHERE dummy = 'Y'; -- Will raise STANDARD.NO_DATA_FOUND
          EXCEPTION
            WHEN NO_DATA_FOUND THEN
              DBMS_OUTPUT.PUT_LINE('No data found!'); -- Won't be executed, as NO_DATA_FOUND was overriden, confusing!
            WHEN OTHERS THEN
              DBMS_OUTPUT.PUT_LINE('Unknown error!'); -- *Will* be executed
          END;
          /
          

          Compliant solution

          SET SERVEROUTPUT ON
          
          DECLARE
            my_own_exception EXCEPTION; -- Compliant
          
            d VARCHAR2(1);
          BEGIN
            SELECT dummy INTO d FROM DUAL WHERE dummy = 'Y';
          EXCEPTION
            WHEN NO_DATA_FOUND THEN
              DBMS_OUTPUT.PUT_LINE('No data found!'); -- *Will* be executed
            WHEN OTHERS THEN
              DBMS_OUTPUT.PUT_LINE('Unknown error!');
          END;
          /
          
            Available In:
          • SonarQube IdeCatch issues on the fly,
            in your IDE
          • SonarQube CloudDetect issues in your GitHub, Azure DevOps Services, Bitbucket Cloud, GitLab repositories
          • SonarQube ServerAnalyze code in your
            on-premise CI
            Developer Edition
            Available Since
            9.1

          © 2026 SonarSource Sàrl. All rights reserved.

          Privacy Policy | Cookie Policy | Terms of Use