How to use expdp dumpfile as external oracle_datapump - oracle

I couldn't use dump expdp output file in to external table with access driver.
Is it possible to use expdp output file in to external table?
Is there any special solution for this case or the structure is so different?
script :
CREATE TABLE item_import (
item_id NUMBER
, item_barcode VARCHAR2(20)
, item_type NUMBER
, item_title VARCHAR2(60)
, item_subtitle VARCHAR2(60)
, item_rating VARCHAR2(8)
, item_rating_agency VARCHAR2(4)
, item_release_date DATE
, created_by NUMBER
, creation_date DATE
, last_updated_by NUMBER
, last_update_date DATE)
ORGANIZATION EXTERNAL
( TYPE oracle_datapump
DEFAULT DIRECTORY "download"
LOCATION ('item_export.dmp')
);
ERROR at line 1:
ORA-29913: error IN executing ODCIEXTTABLEOPEN callout

seems that you wrong the table definition.
Try the following:
CREATE TABLE inventories_xt
ORGANIZATION EXTERNAL
(
TYPE ORACLE_DATAPUMP
DEFAULT DIRECTORY def_dir1
LOCATION ('inv_xt.dmp')
)
AS SELECT * FROM inventories;
Pls. Review the following:
The ORACLE_DATAPUMP Access Driver

Related

SQL Server Polybase create external table ERROR to Oracle with column datatype TIMESTAMP WITH TIME ZONE

Created database scoped credential and an external datasource to Oracle OK.
Creating external table on Orcle table with a column datatype TIMESTAMP WITH TIME ZONE fails no matter what datatype I try to use.
CREATE EXTERNAL TABLE MYSCHEMA.MY_EXT_TABLE
(
SOMECOL NVARCHAR(21) COLLATE Finnish_Swedish_BIN, -- OK
SOME_DATETIME DATETIME2, -- OK
SOME_DATE_COMM DATE,-- OK
SOME_FLOAT float,-- OK
SOME_TIMESTAMP datetimeoffset(7) -- NOK
)
WITH
(
LOCATION = N'ORACLEDATABASE.SCHEMA.TABLE',
DATA_SOURCE = my_oracle_ds
)
GO
Fails with error:
Msg 105083, Level 16, State 1, Line 2
105083;The following columns in the user defined schema are incompatible with the external table schema for table 'SOME_TABLE': 'SOME_TIMESTAMP' failed to be reflected with the error: 'The detected backend type TIMESTAMP(6) WITH TIME ZONE is not supported for external generic tables.'
I tried with datetime, datetime2, datetimeoffset, NVARCHAR but the same error occurs.
Is there a workaround for polybase/generic tables or do I have to skip these columns?
CREATE EXTERNAL TABLE MYSCHEMA.MY_EXT_TABLE
(
SOMECOL NVARCHAR(21) COLLATE Finnish_Swedish_BIN,
SOME_DATETIME DATETIME2,
SOME_DATE_COMM DATE,
SOME_FLOAT FLOAT,
SOME_TIMESTAMP TO_TIMESTAMP_TZ('America/Los_Angeles', 'TZR')
) WITH ( LOCATION = N'ORACLEDATABASE.SCHEMA.TABLE' , DATA_SOURCE = my_oracle_ds ) GO

Unable to load data using external table

I'm trying to load data in an external table from a csv file.
Following is my fragment:
create table emp_ext
(
eid number,ename char(9)
)
organization external
(
TYPE ORACLE_LOADER
DEFAULT DIRECTORY test
ACCESS PARAMETERS
(
RECORDS DELIMITED BY NEWLINE
FIELDS TERMINATED BY ','
(
eid number,
ename char(9)
)
)
LOCATION('C:\Users\99002971\Desktop\empf.csv')
)
create directory test as 'C:\Users\99002971\Desktop'
grant read on directory test to matuat35 // granted using another user
When i do select * from emp_ext , i get following errors:
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 ""identifier:expecting one of :"binary_float,binary_double,comma,char,date,double"
KUP-01008:the bad identifier was double
KUP-01007:at line 4 column 12
Please help
The datatype_spec section of the external table documenation shows that number isn't recognised by the loader driver. In your code that is being seen as an identifier rather than a data type, hence the error.
You can use oracle_number, or unsigned integer since it's presumably always going to be a positive integer for an employee ID; or leave it untyped and allow implicit conversion to the table column type.
Your location should also only specify the file name within the directory, not the full path:
create table emp_ext
(
eid number,ename varchar2(15)
)
organization external
(
TYPE ORACLE_LOADER
DEFAULT DIRECTORY test
ACCESS PARAMETERS
(
RECORDS DELIMITED BY NEWLINE
FIELDS TERMINATED BY ','
(
eid unsigned integer external(9),
ename char(15)
)
)
LOCATION('empf.csv')
)
Or more simply, but relying on implicit conversion:
...
ACCESS PARAMETERS
(
RECORDS DELIMITED BY NEWLINE
FIELDS TERMINATED BY ','
(
eid,
ename char(15) rteim
)
)
LOCATION('empf.csv')
)

Oracle external tables

I'm struggling with an Oracle external table, although I researched the Oracle forums. Still, no success.
Let's suppose I have a simple table
DESCRIBE PRODUCTS
Name Null Type
------------------------------ -------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
ID NOT NULL NUMBER
NAME VARCHAR2(30)
VALUE NUMBER(5,2)
DEP VARCHAR2(30)
COUNT NUMBER(3)
Then, I created an oracle folder:
CREATE OR REPLACE DIRECTORY ext_prod_dir AS 'c:\';
I save the content of that table in a .lst file
spool c:\products.lst
select p.id || ';' || p.name || ';' || p.value || ';' || p.dep || ';' || p.count FROM products p;
spool off;
P.ID||';'||P.NAME||';'||P.VALUE||';'||P.DEP||';'||P.COUNT
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1;Settlers of Catan;29,95;Toys;3
2;DVD Player;82,97;Electronics;2
3;Red Shirt;12,49;Clothes;3
4;Black Leather Couch;399,99;Furniture;5
5;Oak Cofee Table;223,99;Furniture;5
6;Technodrome;27,99;Toys;4
7;Oh Cereal;3,95;Foods;1
8;Game Console;299,95;Toys;2
9;Video Game;29,95;Toys;3
10;Lawn Chair;34,99;Furniture;11
11;Dog Toy Bone;34,99;Toys;9
12;Heated Blanket;27,95;Toys;8
13;Flux Capacitor;27,95;Toys;7
14;Chocolate Pie;3,14;Foods;7
Then I tried to create the external table:
CREATE TABLE products_ext
(ID NUMBER,
NAME VARCHAR2(30),
VALUE NUMBER(5,2),
DEP VARCHAR2(30),
COUNT NUMBER(3))
ORGANIZATION EXTERNAL
(TYPE oracle_loader DEFAULT DIRECTORY ext_prod_dir
ACCESS PARAMETERS
(RECORDS DELIMITED BY NEWLINE
FIELDS TERMINATED BY ';'
MISSING FIELD VALUES ARE NULL
BADFILE ext_prod_dir:'products.bad_xt'
LOGFILE ext_prod_dir:'products.log_xt'
(ID CHAR(6),
NAME CHAR(30),
VALUE CHAR(8),
DEP CHAR(30),
COUNT CHAR(3)))
location ('products.lst')
) REJECT LIMIT UNLIMITED
So far so good. Then when I select data from the external table, I got:
ORA-29913: error in executing ODCIEXTTABLEOPEN callout
ORA-29400: data cartridge error
KUP-00554: error encontered while parsing access parameters
KUP-01005: syntax error: found "badfile": expecting one of: "column (,reject"
KUP-01007: at line 4 column 7
I tried a huge amount of things, but I got variations on this error. Best thing I accomplished was that I got rid of error, but the table was empty. I would be very much indebted If someone with more experience can point me in the right direction.
BADFILE and LOGFILE are not part of the FIELDS clause. So, move them above the FIELDS TERMINATED.
CREATE TABLE products_ext
(ID NUMBER,
NAME VARCHAR2(30),
VALUE NUMBER(5,2),
DEP VARCHAR2(30),
COUNT NUMBER(3))
ORGANIZATION EXTERNAL
(TYPE oracle_loader DEFAULT DIRECTORY ext_prod_dir
ACCESS PARAMETERS
(RECORDS DELIMITED BY NEWLINE
BADFILE ext_prod_dir:'products.bad_xt'
LOGFILE ext_prod_dir:'products.log_xt'
FIELDS TERMINATED BY ';'
MISSING FIELD VALUES ARE NULL
(ID CHAR(6),
NAME CHAR(30),
VALUE CHAR(8),
DEP CHAR(30),
COUNT CHAR(3)))
LOCATION ('products.lst')
) REJECT LIMIT UNLIMITED
Also, you said when you got rid of the error, the table was empty. Did you check the logfile? If the error is with the VALUE column, then check NLS_NUMERIC_CHARACTERS parameter
in view v$nls_parameters.
select * from v$nls_parameters;
Check if the decimal marker is indeed a comma. If not either update this parameter or change it in the data file.

Oracle 10G external table error

I have created the following external table on Oracle 10G.
connect system/password as SYSDBA
create or replace directory ext_tab as 'C:\Suman\External_Tables';
CREATE TABLE emp_ext_3(
empno NUMBER(4), first_name CHAR(20), last_name CHAR(20), dob CHAR(10))
ORGANIZATION EXTERNAL(
TYPE ORACLE_LOADER DEFAULT DIRECTORY ext_tab
ACCESS PARAMETERS
(
RECORDS DELIMITED BY NEWLINE
NOBADFILE
NOLOGFILE
SKIP 1
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LRTRIM
MISSING FIELD VALUES ARE NULL
REJECT ROWS WITH ALL NULL FIELDS
(empno INTEGER EXTERNAL (4),
first_name CHAR(20),
last_name CHAR(20),
dob CHAR(10) DATE_FORMAT DATE MASK "dd/mm/yyyy")
)
LOCATION ('employee1.dat')
)
PARALLEL
REJECT LIMIT 0;
Now If I try to execute select command, I am getting following error.
SQL> select * from "SYSTEM"."EMP_EXT_3";
select * from "SYSTEM"."EMP_EXT_3"
*
ERROR at line 1:
ORA-29913: error in executing ODCIEXTTABLEOPEN callout
ORA-29400: data cartridge error
KUP-04040: file employee1.dat in EXT_TAB not found
ORA-06512: at "SYS.ORACLE_LOADER", line 19
But I have the file "employee1.dat" in 'C:\Suman\External_Tables'. Can someone please help me on why I am getting this error?
The Oracle server is looking for a file in the following location: 'C:\Suman\External_Tables'. That directory is on the Oracle server machine, not your local Windows client machine.

Oracle multiple statments do not run correctly

I have a file with 3 "create type" statements. I do not understand why, when I run the script it creates only the first type. When I open created type I see all three create statements inside. What am I missing here?
CODE:
create type SplitPathTableType as table of varchar2(450);
create TYPE TSMNodesRecord AS OBJECT (
NodeID number(20),
IsDataNode number(1),
Path nvarchar2 (450),
ParentID number(20),
TimeStep number(20)
);
create type TSMNODESTABLE as table of TSMNODESRECORD;
You need / after each statement...
create type SplitPathTableType as table of varchar2(450);
/
create TYPE TSMNodesRecord AS OBJECT (
NodeID number(20),
IsDataNode number(1),
Path nvarchar2 (450),
vParentID number(20),
TimeStep number(20)
);
/
create type TSMNODESTABLE as table of TSMNODESRECORD;
/

Resources