Raise applocation error : raise application error : PL SQL Programming : Oracle PL/SQL Tutorial

Oracle PL/SQL Tutorial
1. Introduction
2. Query Select
3. Set
4. Insert Update Delete
5. Sequences
6. Table
7. Table Joins
8. View
9. Index
10. SQL Data Types
11. Character String Functions
12. Aggregate Functions
13. Date Timestamp Functions
14. Numerical Math Functions
15. Conversion Functions
16. Analytical Functions
17. Miscellaneous Functions
18. Regular Expressions Functions
19. Statistical Functions
20. Linear Regression Functions
21. PL SQL Data Types
22. PL SQL Statements
23. PL SQL Operators
24. PL SQL Programming
25. Cursor
26. Collections
27. Function Procedure Packages
28. Trigger
29. SQL PLUS Session Environment
30. System Tables Data Dictionary
31. Object Oriented
32. XML
33. Large Objects
34. Transaction
35. User Privilege
Java
Java Tutorial
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Oracle PL/SQL Tutorial » PL SQL Programming » raise application error 
24. 15. 2. Raise applocation error


SQL>
SQL> -- create demo table
SQL> create table Employee(
  2    ID                 VARCHAR2(BYTE)         NOT NULL,
  3    First_Name         VARCHAR2(10 BYTE),
  4    Last_Name          VARCHAR2(10 BYTE),
  5    Start_Date         DATE,
  6    End_Date           DATE,
  7    Salary             Number(8,2),
  8    City               VARCHAR2(10 BYTE),
  9    Description        VARCHAR2(15 BYTE)
 10  )
 11  /

Table created.

SQL>
SQL> -- display data in the table
SQL> select from Employee
  2  /

no rows selected

SQL>
SQL> create or replace trigger emp_biu
  2  BEFORE INSERT OR UPDATE
  3  of salary
  4  on employee
  5  for each row
  6  declare
  7      v_error VARCHAR2(2000);
  8  begin
  9      if :new.salary > 10000
 10      then
 11          v_error:=:old.first_name||' cannot have that much!';
 12          raise_application_error(-20999,v_error);
 13      end if;
 14
 15
 16  end;
 17  /

Trigger created.

SQL> insert into Employee(ID,  First_Name, Last_Name, Start_Date,                     End_Date,                       Salary, City,        Description)
  2                values('08','James',    'Cat',     to_date('19960917','YYYYMMDD'), to_date('20020415','YYYYMMDD'), 11232.78,'Vancouver', 'Tester')
  3  /
insert into Employee(ID,  First_Name, Last_Name, Start_Date,                     End_Date,               Salary, City,        Description)
            *
ERROR at line 1:
ORA-20999:  cannot have that much!
ORA-06512: at "JAVA2S.EMP_BIU", line 7
ORA-04088: error during execution of trigger 'JAVA2S.EMP_BIU'


SQL>
SQL>
SQL> -- clean the table
SQL> drop table Employee
  2  /

Table dropped.

SQL>
SQL>
SQL>

        
24. 15. raise application error
24. 15. 1. Using RAISE_APPLICATION_ERROR
24. 15. 2. Raise applocation error
Home | Contact Us
Copyright 2003 - 07 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.