Ora 29400 data cartridge error

I got " ORA-29400: data cartridge error "  error in Oracle database.

June 3, 2021

I got ” ORA-29400: data cartridge error ”  error in Oracle database.

ORA-29400: data cartridge error

Details of error are as follows.

ORA-29400: data cartridge error
Cause: An error has occurred in a data cartridge external procedure. This message will be
 followed by a second message giving more details about the data cartridge error.
Action: See the data cartridge documentation for an explanation of the second error message.
When selecting from an external table , you get the following error:

SQL> select * from sys.empxt;
select * from sys.empxt
*
ERROR at line 1:
ORA-29913: error in executing ODCIEXTTABLEOPEN callout
ORA-29400: data cartridge error
KUP-04040: file emp1.dat in EMP_DIR not found
ORA-06512: at "SYS.ORACLE_LOADER", line 14
ORA-06512: at line 1

When analyzing the table, you get a similar message:

SQL> execute sys.dbms_stats.gather_table_stats('SYS','EMPXT');
BEGIN sys.dbms_stats.gather_table_stats('SYS','EMPXT'); END;
*
ERROR at line 1:
ORA-29913: error in executing ODCIEXTTABLEOPEN callout
ORA-29400: data cartridge error
KUP-04040: file emp1.dat in EMP_DIR not found
ORA-06512: at "SYS.DBMS_STATS", line 7161
ORA-06512: at "SYS.DBMS_STATS", line 7174
ORA-06512: at line 1

or:

ORA-20011: Approximate NDV failed: ORA-29913: error in executing ODCIEXTTABLEOPEN callout
ORA-29400: data cartridge error
KUP-04040: file <file_name> in <directory_name> not found

data cartridge error

This ORA-29400 is related with the error has occurred in a data cartridge external procedure. This message will be
followed by a second message giving more details about the data cartridge error.

See the data cartridge documentation for an explanation of the second error message.

The flat files associated to the external table (emp1.dat, emp2.dat) do not exist in the OS directory pointed by the logical directory EMP_DIR.

Copy/move/recreate the flat file emp1.dat so that it exists in the OS directory pointed by the logical EMP_DIR directory.

SQL> select * from dba_directories ;




OWNER         DIRECTORY_NAME         DIRECTORY_PATH
------        --------------         -----------------------
SYS           EMP_DIR                /oradata/external_files


     
$ mv /tmp/emp1.dat /oradata/external_files

If the problem still persists:

SQL> select * from sys.empxt;
select * from sys.empxt
*
ERROR at line 1:
ORA-29913: error in executing ODCIEXTTABLEOPEN callout
ORA-29400: data cartridge error
KUP-04040: file emp2.dat in EMP_DIR not found
ORA-06512: at "SYS.ORACLE_LOADER", line 14
ORA-06512: at line 1

then be sure that all OS flat files associated to the external table exist in the OS directory pointed by the logical EMP_DIR directory:

SQL> select * from dba_external_locations
2 where table_name='EMPXT';

OWNER     TABLE_NAME     LOCATION    DIRECTORY_OWNER     DIRECTORY_NAME
-----     -------------  --------    ---------------     ---------------
SYS       EMPXT          emp1.dat    SYS                 EMP_DIR
SYS       EMPXT          emp2.dat    SYS                 EMP_DIR




$ mv /tmp/emp2.dat /oradata/external_files

SQL> select * from sys.empxt; 

EMPNO     ENAME     JOB        MGR     HIREDATE    SAL   COMM   DEPTNO
------    -----     --------   -----   ---------   ----  ------ ------
7369     SMITH      CLERK      7902    17-DEC-80   150   0       20
7499     ALLEN      SALESMAN   7698    20-FEB-81   150   0       30
7521     WARD       SALESMAN   7698    22-FEB-81   150   0       30
...

 

SQL> execute sys.dbms_stats.gather_table_stats('SYS','EMPXT');
PL/SQL procedure successfully completed.

Do you want to learn Oracle Database for Beginners, then read the following articles.

Oracle Tutorial | Oracle Database Tutorials for Beginners ( Junior Oracle DBA )

 1,523 views last month,  1 views today

Always check out the original article at http://www.oraclequirks.com for latest comments, fixes and updates.

The pair ORA-29913/ORA-29400 is a sort of catch-all exception embedding KUP-XXXXX error codes that further specify the type of problem encountered with the definition of an external table.
The type of errors encountered spans from syntax errors to missing files or privileges.

For instance, yesterday i got this one when i forgot to specify a keyword in the external table definition.

CREATE TABLE "IMP_BAD_BOXES"
( "TOTE_ID" NUMBER(8,0),
"DEPT" VARCHAR2(2 BYTE),
"CREATED" DATE
)
ORGANIZATION EXTERNAL
( TYPE ORACLE_LOADER
DEFAULT DIRECTORY "IMPORT_DIR"
ACCESS PARAMETERS
(LOGFILE 'BOXES.log'
FIELDS
MISSING FIELD VALUES ARE NULL
REJECT ROWS WITH ALL NULL FIELDS (
CREATED POSITION(1:14) CHAR DATE_FORMAT DATE MASK "YYYYMMDDHH24MISS",
TOTE_ID POSITION(15:22) CHAR,
DEPT POSITION(23:24) CHAR)
)
LOCATION
( 'BOXES.dat')
);

select * from IMP_BAD_BOXES;

ORA-29913: error in executing ODCIEXTTABLEOPEN callout
ORA-29400: data cartridge error
KUP-00554: error encountered while parsing access parameters
KUP-01005: syntax error: found "logfile": expecting one of: "column, ..."
KUP-01007: at line 1 column 1

I marked in red color the position in the statement that caused the run-time error.
Note indeed that when you create the table, no issues are reported, you won’t know if it works until you go live.

So, in the end, this verbose error message was to report that i forgot to specify the keyword RECORDS before LOGFILE.
If you look at the syntax diagram of the ACCESS PARAMETERS clause (ver. 10R1), you’ll notice that there are four distinct sub-clauses.
LOGFILE
belongs to the record format sub-clause. This means that you cannot specify any keyword in this sub-clause if you haven’t specified the RECORDS keyword first.
Note also that from a syntax standpoint it is perfectly legitimate to write the RECORDS keyword alone, but if you do not add DELIMITED BY NEWLINE ( or some other specification) then the record terminator will remain undefined, resulting in the following run-time error:

CREATE TABLE "IMP_BAD_BOXES"
( "TOTE_ID" NUMBER(8,0),
"DEPT" VARCHAR2(2 BYTE),
"CREATED" DATE
)
ORGANIZATION EXTERNAL
( TYPE ORACLE_LOADER
DEFAULT DIRECTORY "IMPORT_DIR"
ACCESS PARAMETERS
(RECORDS
LOGFILE 'BOXES.log'
FIELDS
MISSING FIELD VALUES ARE NULL
REJECT ROWS WITH ALL NULL FIELDS (
CREATED POSITION(1:14) CHAR DATE_FORMAT DATE MASK "YYYYMMDDHH24MISS",
TOTE_ID POSITION(15:22) CHAR,
DEPT POSITION(23:24) CHAR)
)
LOCATION
( 'BOXES.dat')
);
ORA-29913: error in executing ODCIEXTTABLEFETCH callout
ORA-29400: data cartridge error
KUP-04038: internal error: unknown record type

So, my original statement must be rewritten as:

CREATE TABLE "IMP_BAD_BOXES"
( "TOTE_ID" NUMBER(8,0),
"DEPT" VARCHAR2(2 BYTE),
"CREATED" DATE
)
ORGANIZATION EXTERNAL
( TYPE ORACLE_LOADER
DEFAULT DIRECTORY "IMPORT_DIR"
ACCESS PARAMETERS
(RECORDS DELIMITED BY NEWLINE
LOGFILE 'BOXES.log'
FIELDS
MISSING FIELD VALUES ARE NULL
REJECT ROWS WITH ALL NULL FIELDS (
CREATED POSITION(1:14) CHAR DATE_FORMAT DATE MASK "YYYYMMDDHH24MISS",
TOTE_ID POSITION(15:22) CHAR,
DEPT POSITION(23:24) CHAR)
)
LOCATION
( 'BOXES.dat')
);

But how do i put the log file in directory other than IMPORT_DIR?
While the official documentation states that one can write a file location as directory:filename, in the reality it turns out that one must enclose the file name in single quotes, otherwise the following syntax error is returned:

CREATE TABLE "IMP_BAD_BOXES"
( "TOTE_ID" NUMBER(8,0),
"DEPT" VARCHAR2(2 BYTE),
"CREATED" DATE
)
ORGANIZATION EXTERNAL
( TYPE ORACLE_LOADER
DEFAULT DIRECTORY "LOG_DIR"
ACCESS PARAMETERS
(RECORDS DELIMITED BY NEWLINE
LOGFILE 'BOXES.log'
FIELDS
MISSING FIELD VALUES ARE NULL
REJECT ROWS WITH ALL NULL FIELDS (
CREATED POSITION(1:14) CHAR DATE_FORMAT DATE MASK "YYYYMMDDHH24MISS",
TOTE_ID POSITION(15:22) CHAR,
DEPT POSITION(23:24) CHAR)
)
LOCATION
( IMPORT_DIR:BOXES.dat)
);
ORA-00905: missing keyword

On the other hand, if you put the directory specifier inside the quotes too, you’ll get the following run-time error:

CREATE TABLE "IMP_BAD_BOXES"
( "TOTE_ID" NUMBER(8,0),
"DEPT" VARCHAR2(2 BYTE),
"CREATED" DATE
)
ORGANIZATION EXTERNAL
( TYPE ORACLE_LOADER
DEFAULT DIRECTORY "LOG_DIR"
ACCESS PARAMETERS
(RECORDS DELIMITED BY NEWLINE
LOGFILE 'BOXES.log'
FIELDS
MISSING FIELD VALUES ARE NULL
REJECT ROWS WITH ALL NULL FIELDS (
CREATED POSITION(1:14) CHAR DATE_FORMAT DATE MASK "YYYYMMDDHH24MISS",
TOTE_ID POSITION(15:22) CHAR,
DEPT POSITION(23:24) CHAR)
)
LOCATION
('IMPORT_DIR:BOXES.dat')
);
ORA-29913: error in executing ODCIEXTTABLEOPEN callout
ORA-29400: data cartridge error
KUP-04040: file IMPORT_DIR:BOXES.dat in LOG_DIR not found

Finally, here is the correct syntax in blue color:

CREATE TABLE "IMP_BAD_BOXES"
( "TOTE_ID" NUMBER(8,0),
"DEPT" VARCHAR2(2 BYTE),
"CREATED" DATE
)
ORGANIZATION EXTERNAL
( TYPE ORACLE_LOADER
DEFAULT DIRECTORY "LOG_DIR"
ACCESS PARAMETERS
(RECORDS DELIMITED BY NEWLINE
LOGFILE 'BOXES.log'
FIELDS
MISSING FIELD VALUES ARE NULL
REJECT ROWS WITH ALL NULL FIELDS (
CREATED POSITION(1:14) CHAR DATE_FORMAT DATE MASK "YYYYMMDDHH24MISS",
TOTE_ID POSITION(15:22) CHAR,
DEPT POSITION(23:24) CHAR)
)
LOCATION
(IMPORT_DIR:'BOXES.dat')
);

It is up to you to decide whether you want to make the DEFAULT DIRECTORY the place where the source file is read from or the folder where the log files are written to.
Depending on the situation, you may need the appropriate READ and WRITE privileges on it.

As a last note, in case you wonder what would happen if you ALTER the table instead of dropping and re-creating it, you may want to know that it would perfectly possible to execute a statement like this:

ALTER TABLE IMP_BAD_BOXES
ACCESS PARAMETERS (
RECORDS DELIMITED BY NEWLINE
LOGFILE 'boxes.log');

however this statement will wipe out the previous definition of ACCESS PARAMETERS, because it doesn’t add just a LOGFILE, but replaces the ACCESS PARAMETERS as a whole.
So, don’t forget to include the whole sub-clause again if you plan to use ALTER TABLE, as follows:

ALTER TABLE IMP_BAD_BOXES
ACCESS PARAMETERS
(RECORDS DELIMITED BY NEWLINE
LOGFILE 'BOXES.log'
FIELDS
MISSING FIELD VALUES ARE NULL
REJECT ROWS WITH ALL NULL FIELDS (
CREATED POSITION(1:14) CHAR DATE_FORMAT DATE MASK "YYYYMMDDHH24MISS",
TOTE_ID POSITION(15:22) CHAR,
DEPT POSITION(23:24) CHAR)
);

Finally, let me provide a full-fledged example of external table where every log file goes to its own place:

ALTER TABLE IMP_BAD_BOXES
DEFAULT DIRECTORY IMPORT_DIR
ACCESS PARAMETERS
(RECORDS DELIMITED BY NEWLINE
LOGFILE LOG_DIR:'BOXES.log'
DISCARDFILE DISCARD_DIR:'DISCARDS.log'
BADFILE BAD_DIR:'BAD.log'
FIELDS
MISSING FIELD VALUES ARE NULL
REJECT ROWS WITH ALL NULL FIELDS (
CREATED POSITION(1:14) CHAR DATE_FORMAT DATE MASK "YYYYMMDDHH24MISS",
TOTE_ID POSITION(15:22) CHAR,
DEPT POSITION(23:24) CHAR)
)
LOCATION ('BOXES.dat');

As you can see i specified the DEFAULT DIRECTORY clause without embedding the directory object name in double quotes. You must use double quotes if the directory object name is case sensitive otherwise always use uppercase letters.
Do not use single quotes for the directory object name or you’ll get ORA-22929.

See message translations for ORA-29400 and search additional resources.

ORA-20011 ORA-29913 and ORA-29400 with KUP-04040 Errors from DBMS_STATS.GATHER_STATS_JOB


<<Back to DB Administration Main Page

ORA-20011: Approximate NDV failed: ORA-29913: error in executing ODCIEXTTABLEOPEN callout

DBMS_STATS: GATHER_STATS_JOB encountered errors.  Check the trace file.
Errors in file /u01/diag/rdbms/orcl1d/ORCL1D/trace/ORCL1D_j000_24858.trc:
ORA-20011: Approximate NDV failed: ORA-29913: error in executing ODCIEXTTABLEOPEN callout
ORA-29400: data cartridge error
KUP-04040: file PSG_XVD.csv in DUMP_DATA not found
Tue Sep 10 22:05:06 2019



Cause
The primary cause of this issue is that an OS file for an «external table» existed at some point in time but does not now. However, the database still believes the OS file for the table exists since the dictionary information about the object has not been modified to reflect the change. When DBMS_STATS is run against the table in question, it makes a call out to the external table which fails because the object is not there.



Solution
Clean up the orphaned dictionary entries.

For Temporary Datapump External Table

check out the following document from oracle support and follow the steps accordingly.


Document 10327346.8 Bug 10327346 — DBMS_WORKLOAD_CAPTURE does not drop external tables (causing ORA-20011 from DBMS_STATS)
Document 336014.1 How To Cleanup Orphaned DataPump Jobs In DBA_DATAPUMP_JOBS ?

Other External Table


With cases where specific External tables (be they Demo Schema tables or other tables) are missing, the process for handling them is much the same and can be resolved by following the procedures below. For example, if the additional error is ‘error opening file ../demo/schema/log/ext_1v3.log’, then this indicates that there is a problem opening or locating the log file from the demo schema directory. The implication is that the demo tables have not been cleared up correctly:
Locate the files for these tables in their directory.

undefine owner
undefine table_pattern

select el.table_name, el.owner, dir.directory_path||’/’||dir.directory_name «path»
from dba_external_locations el
, dba_directories dir
where el.table_name like ‘%&&table_pattern%’
and el.owner like ‘%&&owner%’
and el.directory_owner = dir.owner
and el.directory_name = dir.directory_name
order by 1, 2;


  • It may be that the files still exist but they have just been renamed or re-located.
  • It may be that the directory path itself does not exists on the server.

If file has been renamed or re-located you can restore back the file to avoid the problem.

If the file has been removed or the directory itself has been deleted then follow either the following steps:

Lock the statistics on these tables by using the following command:

DBMS_STATS.LOCK_TABLE_STATS (‘HR’,’EMP’);

OR
Remove the dictionary object for the external table. DROP TABLE HR.EMP;

More on locking unlocking Stats read here 

I was doing import of a table and started noticing the below error. Even though the database was same.


Tried different methods but it didn’t work. In Oracle support it was mentioned that I may be hitting a bug  and i may have to set NLS_LENGTH_SEMANTICS to char at DB level which was set to byte.


I noticed the table carefully and saw it has a dependency on a Oracle TYPE. 


When i saw its script saw that it was varchar2(20)


CREATE OR REPLACE TYPE ORAUSER1.OFFSET_HDR IS VARRAY(50) of VARCHAR2(20); 



SO I created it manually with an option of «char« in datatype.



SQL> CREATE OR REPLACE TYPE ORAUSER2.OFFSET_HDR IS VARRAY(50) of VARCHAR2(20 char)
  2  /


Type created.


Post that the table was imported successfully.



oracle@linux01:/home/oracle(ORADB)$ impdp / directory=DB_EXP_MOUNT dumpfile=exp_365137_2_%U.dmp logfile=imp_365137_2.log remap_schema=ORAUSER1:ORAUSER2 transform=oid:n parallel=4 cluster=no


Import: Release 12.1.0.2.0 — Production on Thu Jul 12 23:14:07 2018


Copyright (c) 1982, 2014, Oracle and/or its affiliates.  All rights reserved.


Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 — 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, Oracle Label Security,
OLAP, Advanced Analytics, Oracle Database Vault and Real Application Testin
Master table «OPS$oracle».»SYS_IMPORT_FULL_05″ successfully loaded/unloaded
Starting «OPS$oracle».»SYS_IMPORT_FULL_05″:  /******** directory=DB_EXP_MOUNT dumpfile=exp_365137_2_%U.dmp logfile=imp_365137_2.log remap_schema=ORAUSER1:ORAUSER2 transform=oid:n parallel=4 cluster=no parfile=exclude_procobj.par table_exists_action=truncate
Processing object type TABLE_EXPORT/TABLE/PROCACT_INSTANCE
Processing object type TABLE_EXPORT/TABLE/TABLE
Table «ORAUSER2″.»RBX_CURVES» exists and has been truncated. Data will be loaded but all dependent metadata will be skipped due to table_exists_action of truncate
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
ORA-31693: Table data object «ORAUSER2″.»RBX_CURVES» failed to load/unload and is being skipped due to error:
ORA-29913: error in executing ODCIEXTTABLEOPEN callout
ORA-29400: data cartridge error
ORA-39779: type «ORAUSER2″.»OFFSET_HDR» not found or conversion to latest version is not possible
Processing object type TABLE_EXPORT/TABLE/GRANT/OWNER_GRANT/OBJECT_GRANT
Processing object type TABLE_EXPORT/TABLE/INDEX/INDEX
Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Job «OPS$oracle».»SYS_IMPORT_FULL_05″ completed with 1 error(s) at Thu Jul 12 23:14:10 2018 elapsed 0 00:00:02






я установил простой тест внешней таблицы Oracle, который я (наряду с администратором DBA и Unix) не могу получить для работы.

следующее основано на Oracle Концепции Внешних Таблиц. База данных, которую мы используем, — 11g.

это определение внешней таблицы:

drop table emp_load;

CREATE TABLE emp_load
    (employee_number      CHAR(5),
     employee_dob         DATE,
     employee_last_name   CHAR(20),
     employee_first_name  CHAR(15),
     employee_middle_name CHAR(15),
     employee_hire_date   DATE)
  ORGANIZATION EXTERNAL
    (TYPE ORACLE_LOADER
     DEFAULT DIRECTORY defaultdir
     ACCESS PARAMETERS
       (RECORDS DELIMITED BY NEWLINE
        FIELDS (employee_number      CHAR(2),
                employee_dob         CHAR(20),
                employee_last_name   CHAR(18),
                employee_first_name  CHAR(11),
                employee_middle_name CHAR(11),
                employee_hire_date   CHAR(10) date_format DATE mask "mm/dd/yyyy"
               )
       )
     LOCATION ('external_table_test.dat')
);

это содержимое » external_table_test.dat»:

56november, 15, 1980  baker             mary       alice      09/01/2004
87december, 20, 1970  roper             lisa       marie      01/01/1999

Я могу запустить скрипт, который создает «emp_load» без проблем. Я также могу описать стол в порядке. Когда я пытаюсь «выбрать * из emp_load», я получаю следующие ошибки:

SQL> select * from emp_load;
select * from emp_load
              *
ERROR at line 1:
ORA-29913: error in executing ODCIEXTTABLEOPEN callout
ORA-29400: data cartridge error
error opening file /defaultdir/EMP_LOAD_29305.log

правка 1
oracle имеет разрешения на чтение/запись в каталоге.

EDIT 2
Я смог получить эту ошибку, используя следующее определение внешней таблицы:

CREATE TABLE emp_load
    (employee_number      CHAR(3),
     employee_last_name   CHAR(20),
     employee_middle_name CHAR(15),
     employee_first_name  CHAR(15)
     )
  ORGANIZATION EXTERNAL
    (TYPE ORACLE_LOADER
     DEFAULT DIRECTORY defaultdir
     ACCESS PARAMETERS
       (RECORDS DELIMITED BY NEWLINE
        BADFILE DHHSMAPSIS:'EMP.BAD'
        LOGFILE DHHSMAPSIS:'EMP.LOG'
        FIELDS TERMINATED BY ','
       )
    LOCATION ('external_table_test2.dat')
)
REJECT LIMIT UNLIMITED;

мой .файл dat выглядит так…

056,baker,beth,mary
057,smith,teddy,john

мне пришлось установить разрешения на » EMP.ПЛОХО», » EMP.БРЕВНО» & «external_table_test2.dat » до 777, чтобы заставить его работать. Пользователь oracle не владеет этими файлами, но находится в той же группе, что и файлы.

любая идея, почему я не могу заставить это работать, когда я устанавливаю разрешения на эти файлы в 770? Опять же, oracle находится в той же группе, что и эти файлы, поэтому я решил, что 770 будет в порядке для разрешений…

5 ответов


Наша Версия Oracle работает на Red Hat Enterprise Linux. Мы экспериментировали с несколькими различными типами групповых разрешений безрезультатно. Каталог /defaultdir имел группу, которая была вторичной группой для пользователя oracle. Когда мы обновили каталог /defaultdir, чтобы иметь группу «oinstall» (основная группа oracle), я смог выбрать из внешних таблиц под этим каталогом без проблем.

Итак, для других, которые приходят и могут иметь это проблема, сделайте каталог основной группой oracle в качестве группы, и он может решить ее для вас, как и для нас. Мы смогли установить разрешения на 770 в каталоге и файлах, и выбор на внешних таблицах теперь работает нормально.


имейте в виду, что это пользователь, который запускает базу данных oracle, которая должна иметь разрешения на запись в каталог /defaultdir, а не пользователь, вошедший в oracle. Обычно вы запускаете базу данных как пользователь «Oracle». Это не тот же пользователь (обязательно), с которым вы создали внешнюю таблицу.

проверьте права доступа к каталогу.


мы столкнулись с той же проблемой:

ORA-29913: error in executing ODCIEXTTABLEOPEN callout
ORA-29400: data cartridge error error opening file /fs01/app/rms01/external/logs/SH_EXT_TAB_VGAG_DELIV_SCHED.log

в нашем случае у нас был RAC с 2 узлами. После предоставления разрешения на запись в каталог журнала,С обеих сторон, все работало нормально.


У нас была эта ошибка в Oracle RAC 11g в Windows, и решением было создать одно и то же дерево каталогов ОС и внешний файл на обоих узлах.


Если вы хотите создать external_table, все имя поля должно быть записано в верхнем регистре.

сделано.


Понравилась статья? Поделить с друзьями:

Читайте также:

  • Oracle exception raise application error
  • Ora 29278 smtp transient error 421 service not available
  • Ora 01041 внутренняя ошибка hostdef расширение не существует
  • Ora 28547 connection to server failed probable oracle net admin error
  • Oracle exception error text

  • 0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии