开发者

Oracle 11g Creating a custom event trigger

开发者 https://www.devze.com 2023-04-11 22:19 出处:网络
how to Create a Database event trigger called as AuditErr that will fire every time a server error occurs. The

how to Create a Database event trigger called as AuditErr that will fire every time a server error occurs. The error refers to any Oracle error. This trigger can serve as a notification mechani开发者_如何学Gosm to an administrator, by populating an error log table, called server_error_log (use the given SQL script). You should create the error lag table before-hand and when an error happens, the error code and details must be written back to this table.

CREATE TABLE server_error_log ( error_code decimal(6), description varchar2(256) );


You'll have to create a database event trigger:

CREATE TRIGGER log_errors AFTER SERVERERROR ON DATABASE 
   BEGIN
      // log error
   END;

In this trigger, you can use the attribute functions ora_server_error and ora_server_error_msg to retrieve the error stack.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号