Uploaded image for project: 'Rules Repository'
  1. Rules Repository
  2. RSPEC-2450

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

    XMLWordPrintable

    Details

    • Type: Bug Detection
    • Status: Active
    • Resolution: Unresolved
    • Labels:
    • Message:
      "nnn" is an invalid error code.
    • Default Severity:
      Blocker
    • Impact:
      High
    • Likelihood:
      High
    • Default Quality Profiles:
      Sonar way
    • Legacy Key:
      BadRaiseApplicationErrorUsageCheck
    • Covered Languages:
      PL/SQL
    • Remediation Function:
      Constant/Issue
    • Constant Cost:
      1h

      Description

      RAISE_APPLICATION_ERROR may only be called with an error code from -20,000 to -20,999, which is the range reserved for application errors. When called with another value, Oracle raises the exception: ORA-21000: error number argument to raise_application_error of 0 is out of range.

      Noncompliant Code Example

      BEGIN
        RAISE_APPLICATION_ERROR(0, 'This is an application error'); -- Non-Compliant - raises ORA-21000
      END;
      /
      

      Compliant Solution

      BEGIN
        RAISE_APPLICATION_ERROR(-20000, 'This is an application error'); -- Compliant
      END;
      /
      

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            ann.campbell.2 Ann Campbell
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated: