
What is alert log file in Oracle
The alert log file (also referred to as the ALERT.LOG) is a chronological log of messages and errors written out by an Oracle Database. Typical messages found in this file are database startup, shutdown, log switches, space errors, etc. This file should constantly be monitored to detect unexpected messages and corruption.
Oracle will automatically create a new alert log file whenever the old one is deleted.
Alert log location
The location can find out using the parameter background_dump_dest
sqlplus / as sysdba show parameter background_dump_dest
Beginning with Release 11g, the alert log file is written as XML formatted and as a text file (like in previous releases). The default location of both these files is the new ADR home (Automatic Diagnostic Repository, yet another new dump dest in 11g).
The ADR is set by using the DIAGNOSTIC_DEST initialization parameter. But you can still find the alert log location using the parameter background_dump_dest.
background_dump_dest is set like
$diagnostic_dest/diag/rdbms/<db_unique_name>/<instance_name>/trace
11g Alert log new features
Beginning with Release 11g of Oracle Database, the alert log is written as both an XML-formatted file and as a text file, as in earlier releases. Both these log files are stored inside the ADR home. The ADR root directory is known as ADR BASE. The Automatic Diagnostic Repository (ADR) is a directory structure that is stored outside of the database. This parameter is set by DIAGNOSTIC_DEST initialization parameter.
SQL> show parameter diagno
NAME TYPE VALUE
--------------------------- ----------- ------------------------------
diagnostic_dest string /u001/oracle/product/XPROD11g/diag
The location of an ADR home is given by the following path, which starts at the ADR base directory:
ADR_BASE/diag/product_type/product_id/instance_id
For example,
So for RDBMS oracle Home of Database name XPROD
ADR_base/diag/rdbms/XPROD/XPROD
Within the ADR home directory are subdirectories where the database instance stores diagnostic data.
alert Log file,The XML-formatted alert log, trace Background and server process trace files and SQL trace files , text alert.log file , cdump Core files
XML formatted alert.log
The alert log is named log.xml and is stored in the alert subdirectory of ADR home.
To get the log.xml path
ADR_BASE/diag/product_type/product_id/instance_id/alert
From Sqlplus
SQL> select value from v$diag_info where name ='Diag Alert';
ADRCI utility to view a text version of the alert log (with XML tags stripped)
Text formatted alert.log
The alert.log is named alertSID.log and is stored in the trace subdirectory of ADR home.
To view the text-only alert.log file
ADR_BASE/diag/product_type/product_id/instance_id/trace
from sqlplus
SQL> select value from v$diag_info where name ='Diag Trace'; or SQL > Show parameter background_dump_dest
Open file alert_SID.log with a text editor
With 11g ,Oracle provides a way to look the alert log file from the database also. There is a fixed table X$DBGALERTEXT, when you query it, Oracle reads the log.xml from alert directory (which contains all the data what alert.log does), parses it and returns the details back as rows:
SQL> select message_text from X$DBGALERTEXT where rownum desc X$DBGALERTEXT
Name Null? Type
------------------------------- -------- ----------------------------
1 ADDR RAW(4)
2 INDX NUMBER
3 INST_ID NUMBER
4 ORIGINATING_TIMESTAMP TIMESTAMP(3) WITH TIME ZONE
5 NORMALIZED_TIMESTAMP TIMESTAMP(3) WITH TIME ZONE
6 ORGANIZATION_ID VARCHAR2(64)
7 COMPONENT_ID VARCHAR2(64)
8 HOST_ID VARCHAR2(64)
9 HOST_ADDRESS VARCHAR2(16)
10 MESSAGE_TYPE NUMBER
11 MESSAGE_LEVEL NUMBER
12 MESSAGE_ID VARCHAR2(64)
13 MESSAGE_GROUP VARCHAR2(64)
14 CLIENT_ID VARCHAR2(64)
15 MODULE_ID VARCHAR2(64)
16 PROCESS_ID VARCHAR2(32)
17 THREAD_ID VARCHAR2(64)
18 USER_ID VARCHAR2(64)
19 INSTANCE_ID VARCHAR2(64)
20 DETAILED_LOCATION VARCHAR2(160)
21 PROBLEM_KEY VARCHAR2(64)
22 UPSTREAM_COMP_ID VARCHAR2(100)
23 DOWNSTREAM_COMP_ID VARCHAR2(100)
24 EXECUTION_CONTEXT_ID VARCHAR2(100)
25 EXECUTION_CONTEXT_SEQUENCE NUMBER
26 ERROR_INSTANCE_ID NUMBER
27 ERROR_INSTANCE_SEQUENCE NUMBER
28 VERSION NUMBER
29 MESSAGE_TEXT VARCHAR2(2048)
30 MESSAGE_ARGUMENTS VARCHAR2(128)
31 SUPPLEMENTAL_ATTRIBUTES VARCHAR2(128)
32 SUPPLEMENTAL_DETAILS VARCHAR2(128)
33 PARTITION NUMBER
34 RECORD_ID NUMBER
There’s also a fixed table X$DBGDIREXT, which returns all file and directory names under [diagnostic_dest]/diag directory:
SQL> select lpad(' ',lvl,' ')||logical_file file_name from X$DBGDIREXT where rownum < 2;
12c or above Alert log new features
With 12c and above, background_dump_dest is depreciated. We can find the alert log location using below also
adrci
adrci> show alert
adrci> show alert -tail 100
how to check alert log errors in oracle using Unix Command
Go to the background dump directory to run these unix commands
Date and errors in alert.log
cat alert*log | awk 'BEGIN{buf=""} /[0-9]:[0-9][0-9]:[0-9]/{buf=$0} /ORA-/{print buf,$0}'
How to find the Date of startups in the alert.log
cat alert*log | awk 'BEGIN{buf=""} /[0-9]:[0-9][0-9]:[0-9]/{buf=$0} /Starting ORACLE/{print buf,$0}'
How to easily find the Oracle database startup and shutdown time using sqlplus
Here are the steps required on How to easily find the Oracle database startup and shutdown time using sqlplus
step 1) Create a database directory object
create or replace directory data_dir as 'Specify the Backgound dump Dest location' / Directory created. CREATE TABLE alert_log ( text_line varchar2(255)) ORGANIZATION EXTERNAL ( TYPE ORACLE_LOADER DEFAULT DIRECTORY data_dir ACCESS PARAMETERS ( records delimited by newline fields REJECT ROWS WITH ALL NULL FIELDS ) LOCATION ( 'alert_.log' ) ) REJECT LIMIT unlimited / Table created.
step 2) Use the below query to find out the timing
select to_char(last_time,'dd-mon-yyyy hh24:mi') shutdown, to_char(start_time,'dd-mon-yyyy hh24:mi') startup, round((start_time-last_time)2460,2) mins_down, round((last_time-lag(start_time) over (order by r)),2) days_up, case when (lead(r) over (order by r) is null ) then round((sysdate-start_time),2) end days_still_up from ( select r, to_date(last_time, 'Dy Mon DD HH24:MI:SS YYYY') last_time, to_date(start_time,'Dy Mon DD HH24:MI:SS YYYY') start_time from ( select r, text_line, lag(text_line,1) over (order by r) start_time, lag(text_line,2) over (order by r) last_time from ( select rownum r, text_line from alert_log where text_line like '_ _ ::_ 20_' or text_line like 'Starting ORACLE instance %' ) ) where text_line like 'Starting ORACLE instance %' ) /
Related Articles
ORA-00942 table or view does not exist
ora-29913: error in executing odciexttableopen callout
ORA-00257: archiver error. Connect internal only, until freed.
ORA-03113: end-of-file on communication channel
ORA-27154: post/wait create failed during startup
how to find archive log sequence number in oracle
https://docs.oracle.com/cd/B28359_01/server.111/b28310/diag005.htm#ADMIN11267
Not all errors in Oracle are fatal, and that statement applies to data manipulation language statements as well. Even though an error in and of itself may be fatal, when handled properly it becomes benign. The question is this: how do you make an otherwise fatal error benign or harmless? There are at least three ways, two of which you are probably quite familiar with, and a lesser known, but very versatile third method.
The Tried and True Ways
Two methods of capturing DML errors and being able to deal with them in a suitable manner are SQL*Loader and PL/SQL exception handling. If your situation involves uploading data or writing blocks of exception handling code (and only checking for a few errors), then by and large, these manners are suitable. SQL*Loader can provide a wealth of information about a bad record via the log, bad, and discard files, but its usefulness across all DML operations is limited.
PL/SQL exception handling can also capture errors and provide information for feedback, but coding all of the potential places where an integrity error can occur, in addition to keeping track of an exception block’s scope, can grow to be quite tedious. Besides, are you sure you accounted for all of the possible errors? The PL/SQL approach also means having to wrap blocks in an inappropriate manner and repeating the error handling from block to block. The PL/SQL approach also incurs the cost of context switching because of having to switch between SQL and PL/SQL. There has to be a better way, and in this case, there does exist a better way, namely, that of what is referred to as DML error logging.
DML Error Logging Basics
Managing Tables, Chapter 15 of the Administrator’s Guide, explains what takes place during DML error logging.
To use DML error logging, you add a statement clause that specifies the name of an error logging table into which the database records errors encountered during DML operations. When you add this error logging clause to the INSERT
statement, certain types of errors no longer terminate and roll back the statement. Instead, each error is logged and the statement continues. You then take corrective action on the erroneous rows at a later time.
The scenario just shown mentions INSERT, but DML error logging applies to UPDATE and DELETE as well. The basic steps (summarized from the documentation) are to:
1. Optionally create an error logging table. You can create the table manually or use the DBMS_ERRLOG package to automatically create it for you.
2. Execute a DML statement and include an error logging clause. This clause:
-
Optionally references the error logging table that you created. If you do not provide an error logging table name, the database logs to an error logging table with a default name. The default error logging table name is ERR$_ followed by the first 25 characters of the name of the table that is being inserted into.
-
Optionally includes a tag (a numeric or string literal in parentheses) that is added to the error log to help identify the statement that caused the errors. If the tag is omitted, a NULL value is used.
-
Optionally includes a REJECT LIMIT subclause. This subclause indicates the maximum number of errors that can be encountered before the DML statement terminates and rolls back. You can also specify UNLIMITED. The default reject limit is zero, which means that upon encountering the first error, the error is logged and the statement rolls back. For parallel DML operations, the reject limit is applied to each parallel server.
3. Note: If the statement exceeds the reject limit and rolls back, the error logging table retains the log entries recorded so far.
4. Query the error logging table and take corrective action for the rows that generated errors.
If you do create an error logging table, you must include all of the mandatory error logging columns (although they can be created in any order). You may optionally create additional columns, which reference the DML table. An important point to keep in mind is that datatypes of the additional columns must be able to capture or handle the datatype of the DML column. For example, don’t make a number column in the error table when the DML table is trying to use VARCHAR2. Do, however, make the error table column datatype VARCHAR2 when dealing with a number in the DML table. Oracle will handle the casting for you (if it can). VARCHAR2(4000) is pretty much the default datatype you should use for typical DML column datatypes.
The mandatory columns in an (again, optional) error table are:
Column Name |
Datatype |
Description |
ORA_ERR_NUMBER$ |
NUMBER |
Oracle error number |
ORA_ERR_MESG$ |
VARCHAR2(2000) |
Oracle error message text |
ORA_ERR_ROWID$ |
ROWID |
Rowid of the row in error (for update and delete) |
ORA_ERR_OPTYP$ |
VARCHAR2(2) |
Type of operation: I/U/D (merge will include U and I) |
ORA_ERR_TAG$ |
VARCHAR2(2000) |
Value of the tag supplied by the user in the error logging clause |
You have two options with respect to creating an error table. The first is to let Oracle do the work for you, and that requires using the DBMS_ERRLOG package. This built-in will not only create the mandatory columns just mentioned, but will also map the target DML table’s columns. The second and decidedly more difficult way is to manually create the logging table via a data definition language (DDL) CREATE TABLE statement. Under the manual method, you are responsible for ensuring the mandatory parts are in place and for mapping any additional columns.
The only real advantage to manually creating an error logging table is that you can name it whatever you want and add (or not) only some of the DML table’s columns. Otherwise, the table is named ERR$_<first 25 characters of the DML table’s name>.
The DBMS_ERRLOG Package
This package, described in Chapter 38 of Oracle® Database PL/SQL Packages and Types Reference, 10g Release 2 (10.2) employs a security model. For the most part, you can create an error logging table for any table (or view) you own. Some of the package’s input parameters can be null, and the only mandatory input parameter is the name of the DML (or target) table. There is only one procedure in this package, and that is the CREATE_ERROR_LOG procedure. To help prevent a datatype mismatch between the DML and error logging table, you may want to consider using the skip_unsupported input parameter (BOOLEAN, default is false, meaning an unsupported column type will cause the procedure to terminate).
Let’s look at an example/use case for DML error logging. To keep things simple, we will use the EMP table in Scott’s schema. The steps below show how easy it is to create the error logging table. Note how all of the columns in EMP have been mapped to VARCHAR2(4000)’s in ERR$_EMP.
SQL> set serveroutput on
SQL> exec DBMS_ERRLOG.CREATE_ERROR_LOG (‘EMP’);
PL/SQL procedure successfully completed.
SQL> desc err$_emp;
Name Null? Type
———————————————————– ——– —————-
ORA_ERR_NUMBER$ NUMBER
ORA_ERR_MESG$ VARCHAR2(2000)
ORA_ERR_ROWID$ ROWID
ORA_ERR_OPTYP$ VARCHAR2(2)
ORA_ERR_TAG$ VARCHAR2(2000)
EMPNO VARCHAR2(4000)
ENAME VARCHAR2(4000)
JOB VARCHAR2(4000)
MGR VARCHAR2(4000)
HIREDATE VARCHAR2(4000)
SAL VARCHAR2(4000)
COMM VARCHAR2(4000)
DEPTNO VARCHAR2(4000)
Now that the error logging table is created, let’s attempt a DML statement which we know will have an error. Try to duplicate the employee named MILLER.
SQL> INSERT INTO emp values (7934,’MILLER’,’CLERK’,7782,’23-JAN-82′,3900,null,20)
2 LOG ERRORS INTO err$_emp (‘insert example’) REJECT LIMIT 25;
0 rows created.
We failed to insert into EMP, but what is in ERR$_EMP?
As another example, what if the ENAMEs were constrained to be not null? Issue “alter table emp modify (ename not null);” to achieve the desired effect, and then attempt an insert as shown below (with and without the error logging clause).
You have to admit this is much easier than using nested PL/SQL blocks where scope has to be considered to keep an operation running.
In Closing
The utility or usefulness of DML error logging is considerable if your application processes large amounts of records. Instead of (potentially) bombing out after running for hours, you can craft a means of allowing good records to be processed and then come back to problem records at a later time. This approach to programming does not imply you should minimize why an error occurred. Capturing badly formatted data is a clear case of utility, but handling incorrect referential data must be considered as to why or how DML failed.
» See All Articles by Columnist Steve Callan
Steve Callan
Steve is an Oracle DBA (OCP 8i and 9i)/developer working in Denver. His Oracle experience also includes Forms and Reports, Oracle9iAS and Oracle9iDS.
В 10.2 появилось логирование ошибок при выполнение DML команд INSERT, UPDATE, MERGE и DELETE.
Если DML-операция при массовой обработке данных вызывает ошибки при добавлении или изменении, какой либо записи, то вся операция DML будет отменена. Новая инструкция — LOG ERRORS, предназначена для обхода подобных ситуация. Если в процессе выполнения DML операции возникает ошибка, то информация о ней запишется в заранее созданную (при помощи пакета DBMS_ERRLOG) таблицу логов, на которую указывает конструкция LOG ERRORS.
Синтаксис
LOG ERRORS [INTO schema.table] [ (simple_expression) [ REJECT LIMIT {integer|UNLIMITED} ]
REJECT LIMIT
REJECT LIMIT указывает на максимально количество ошибок, которое может произойти, прежде чем statement прервётся.
Представим, что у нас при выполнении statement произойдет 2 ошибки, что будет происходить, при разных значениях REJECT LIMIT.
REJECT LIMIT | Ошибка | Логирование | Транзакция |
---|---|---|---|
0 | отразится ошибка | в логе будет 1 строка | автоматический rollback |
1 | отразится ошибка | в логе будет 2 строки | автоматический rollback |
2, больше и UNLIMITED | ошибки не будет! | в логе будет 2 строки | нужно будет подтвердить или откатить транзацию. |
Пример использования
Создаем таблицу
create table xx_test (id number primary key, field1 varchar2(1), field2 varchar2(10) not null);
Напишем скрипт без использования DML error logging
declare i number; begin i := 0; while i <= 10 loop insert into xx_test (id, field1, field2) values (i, i, i); i := i+1; end loop; end; / ORA-12899: значение для столбца "APPS"."XX_TEST"."FIELD1" слишком велико (фактическое: 2, максимальное: 1) ORA-06512: на line 6
Создаем Error Logging Table
begin dbms_errlog.create_error_log('XX_TEST','ERROR_LOG_XX_TEST') ; end; / PL/SQL procedure successfully completed SQL> desc ERROR_LOG_XX_TEST; Name Type Nullable Default Comments --------------- -------------- -------- ------- -------- ORA_ERR_NUMBER$ NUMBER Y ORA_ERR_MESG$ VARCHAR2(2000) Y ORA_ERR_ROWID$ UROWID(4000) Y ORA_ERR_OPTYP$ VARCHAR2(2) Y ORA_ERR_TAG$ VARCHAR2(2000) Y ID VARCHAR2(4000) Y FIELD1 VARCHAR2(4000) Y FIELD2 VARCHAR2(4000) Y
Добавим в скрипт инструкцию LOG ERRORS
SQL> declare i number; 2 begin 3 i := 0; 4 while i <= 10 loop 5 insert into xx_test (id, field1, field2) 6 values (i, i, i) 7 LOG ERRORS INTO ERROR_LOG_XX_TEST REJECT LIMIT 1; 8 i := i+1; 9 end loop; 10 end; 11 / PL/SQL procedure successfully completed SQL> col num$ for 9999999 SQL> col ora_err_mesg$ for a60 SQL> col typ for a4 SQL> col id for a4 SQL> col field1 for a6 SQL> col field2 for a6 SQL> select ora_err_number$ num$, ora_err_mesg$, ora_err_optyp$ typ, id, field1, field2 from ERROR_LOG_XX_TEST; NUM$ ORA_ERR_MESG$ TYP ID FIELD1 FIELD2 ------- ------------------------------------------------------------ ---- ---- ------ ------ 12899 ORA-12899: значение для столбца "APPS"."XX_TEST"."FIELD1" сл I 10 10 10 ишком велико (фактическое: 2, максимальное: 1)
Есть возможность добавлять некие свои данные в таблицу Error Logging
SQL> declare 2 i number; 3 begin 4 i := 0; 5 while i <= 10 loop 6 insert into xx_test (id, field1, field2) 7 values (i, i, i) 8 LOG ERRORS INTO ERROR_LOG_XX_TEST('i='||to_char(i)) REJECT LIMIT 1; 8 i := i+1; 10 end loop; 11 end; 12 / PL/SQL procedure successfully completed SQL> col num$ for 9999999 SQL> col ora_err_mesg$ for a60 SQL> col typ for a4 SQL> col id for a4 SQL> col field1 for a6 SQL> col field2 for a6 SQL> col ora_err_tag$ for a25 SQL> select ora_err_number$ num$, ora_err_mesg$, ora_err_optyp$ typ, ora_err_tag$, id, field1, field2 from ERROR_LOG_XX_TEST; NUM$ ORA_ERR_MESG$ TYP ORA_ERR_TAG$ ID FIELD1 FIELD2 ------- ------------------------------------------------------------ ---- ------------------------- ---- ------ ------ 12899 ORA-12899: значение для столбца "APPS"."XX_TEST"."FIELD1" сл I i=10 10 10 10 ишком велико (фактическое: 2, максимальное: 1)
Дополнительную информацию можно посмотреть здесь: DML Error Logging in Oracle 10g Database Release 2
Table of Contents
Introduction
LOG ERRORS handles errors quickly and simplifies batch loading.
When you need to load millions of rows of data into a table, the most efficient way is usually to use an INSERT, UPDATE, or MERGE statement to process your data in bulk. Similarly, if you want to delete thousands of rows, using a DELETE statement is usually faster than using procedural code. But what if the data you intend to load contains values that might cause an integrity or check constraint to be violated, or what if some values are too big for the column they are to be loaded into?
You may well have loaded 999,999 rows into your table, but that last row, which violates a check constraint, causes the whole statement to fail and roll back. In situations such as this, you have to use an alternative approach to loading your data.
For example, if your data is held in a file, you can use SQL*Loader to automatically handle data that raises an error, but then you have to put together a control file, run SQL*Loader from the command line, and check the output file and the bad datafile to detect any errors.
If, however, your data is held in a table or another object, you can write a procedure or an anonymous block to process your data row by row, loading the valid rows and using exception handling to process those rows that raise an error. You might even use BULK COLLECT and FORALL to handle data in your PL/SQL routine more efficiently, but even with these improvements, handling your data in this manner is still much slower than performing a bulk load by using a direct-path INSERT DML statement.
Until now, you could take advantage of the set-based performance of INSERT, UPDATE, MERGE, and DELETE statements only if you knew that your data was free from errors; in all other circumstances, you needed to resort to slower alternatives. All of this changes with the release of Oracle Database 10g Release 2, which introduces a new SQL feature called DML error logging.
Efficient Error Handling
DML error logging enables you to write INSERT, UPDATE, MERGE, or DELETE statements that automatically deal with certain constraint violations. With this new feature, you use the new LOG ERRORS clause in your DML statement and Oracle Database automatically handles exceptions, writing erroneous data and details of the error message to an error logging table you’ve created.
Articles Related
The Error Table
Error tables store error details. You can define error tables for tables, views, and materialized views only. Error tables are used for the following purposes:
-
DML error logging (including physical errors).
-
Capturing logical errors when data rules are applied to tables, views, or materialized views.
An error table is generated and deployed along with the base table, view, or materialized view if the shadow table name is set. The error table will have the following columns for DML errors.
Column Name | Description |
---|---|
ORA_ERR_NUMBER$ | Oracle error number |
ORA_ERR_MESG$ | Oracle error message text |
ORA_ERR_ROWID$ | Rowid of the row in error (for update and delete) |
ORA_ERR_OPTYPE$ | Type of operation: insert (I), update (U), delete (D) |
ORA_ERR_TAG$ | Step or detail audit ID from the runtime audit data. This is the STEP_ID column in the runtime view ALL_RT_AUDIT_STEP_RUNS. |
Before you can use the LOG ERRORS clause, you need to create an error logging table, either manually with DDL or automatically with the CREATE_ERROR_LOG procedure in the DBMS_ERRLOG package, whose specification is shown in Listing 1.
Code Listing 1: DBMS_ERRLOG.CREATE_ERROR_LOG parameters
DBMS_ERRLOG.CREATE_ERROR_LOG (
dml_table_name IN VARCHAR2,
err_log_table_name IN VARCHAR2 := NULL,
err_log_table_owner IN VARCHAR2 := NULL,
err_log_table_space IN VARCHAR2 := NULL,
skip_unsupported IN BOOLEAN := FALSE);
All the parameters except DML_TABLE_NAME are optional, and if the optional details are omitted, the name of the error logging table will be ERR$_ together with the first 25 characters of the DML_TABLE_NAME. The SKIP_UNSUPPORTED parameter, if set to TRUE, instructs the error logging clause to skip over LONG, LOB, and object type columns that are not supported and omit them from the error logging table.
With the error logging table created, you can add the error logging clause to most DML statements, using the following syntax:
LOG ERRORS [INTO [schema.]table]
[ (simple_expression) ]
[ REJECT LIMIT {integer|UNLIMITED} ]
The INTO clause is optional; if you omit it, the error logging clause will put errors into a table with the same name format used by the CREATE_ERROR_LOG procedure. SIMPLE_EXPRESSION is any expression that would evaluate to a character string and is used for tagging rows in the error table to indicate the process that caused the error, the time of the data load, and so on. REJECT LIMIT can be set to any integer or UNLIMITED and specifies the number of errors that can occur before the statement fails. This value is optional, but if it is omitted, the default value is 0, which effectively disables the error logging feature.
Type of error handled
The following types of errors are handled by the error logging clause:
-
Column values that are too large
-
Constraint violations (NOT NULL, unique, referential, and check constraints), except in certain circumstances detailed below
-
Errors raised during trigger execution
-
Errors resulting from datatype conversion between a column in a subquery and the corresponding column of the table
-
Partition mapping errors
The following conditions cause the statement to fail and roll back without invoking the error logging capability:
-
Violated deferred constraints
-
Out-of-space errors
-
Any UPDATE operation (UPDATE or MERGE) that raises a unique constraint or index violation
In addition, you cannot track errors in the error logging table for LONG, LOB, or object type columns.
Statement
Creating the err$_sales_target error logging table
SQL> BEGIN
2 DBMS_ERRLOG.CREATE_ERROR_LOG('SALES_TARGET');
3 END;
4 /
PL/SQL procedure successfully completed.
SQL> DESCRIBE err$_sales_target;
Name Null? Type
------------------- ---- -------------
ORA_ERR_NUMBER$ NUMBER
ORA_ERR_MESG$ VARCHAR2(2000)
ORA_ERR_ROWID$ ROWID
ORA_ERR_OPTYP$ VARCHAR2(2)
ORA_ERR_TAG$ VARCHAR2(2000)
SALES_ID VARCHAR2(4000)
CUST_ID VARCHAR2(4000)
PROD_ID VARCHAR2(4000)
CHANNEL_ID VARCHAR2(4000)
TIME_ID VARCHAR2(4000)
PROMO_ID VARCHAR2(4000)
AMOUNT_SOLD VARCHAR2(4000)
QUANTITY_SOLD VARCHAR2(4000)
Violating the constraints and logging the errors with LOG ERRORS
SQL> INSERT /*+ APPEND */
2 INTO sales_target
3 SELECT *
4 FROM sales_src
5 LOG ERRORS
6 REJECT LIMIT UNLIMITED
7 ;
918834 rows created.
Elapsed: 00:00:05.75
SQL> SELECT count(*)
2 FROM err$_sales_target
3 ;
COUNT(*)
-----
9
Elapsed: 00:00:00.06
Documentation / Reference
Recommended Pages
Application — Fault Handling
fault handling Articles Related Application
Oracle — PL/SQL — On Avoiding Termination
Continue PL/SQL execution beyond exceptions. The procedure must continues past any exceptions and completes as many actions as possible. What are my options in PL/SQL for doing this? In Oracle Databas «…
Owb — Error Handling (Error Logging Table and Data Rules)
Error logging enables the processing of DML statements to continue despite errors being encountered during the statement execution. DML error logging is supported for SQL statements such as INSERT, UP «…
PL/SQL — (Procedure Language|PL) SQL
PlSql is the development language of the oracle database. SQL was designed from the start to operate on SETS (ie parallel task) whereas PL/SQL brought a lot in terms of exception handling. Syntax PL/ «…