error while trying to select from external table - oracle

I am getting the below error while trying to select * from ext_poc
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_double, binary_float, comma, char, date, defaultif, decimal, double, float, integer, (, no, nullif, oracle_date, oracle_number, position, raw, recnum, ), unsigned, varrawc, varchar, varraw, varcharc, zoned"
KUP-01008: the bad identifier was: varchar2
KUP-01007: at line 4 column 10
29913. 00000 - "error in executing %s callout"
*Cause: The execution of the specified callout caused an error.
*Action: Examine the error messages take appropriate action.
Below is the ddl for the table:
CREATE TABLE "JDASTG"."EXT_POC"
( "ID" varchar2(100),
"NAME" varchar2(100),
"DOB" varchar2(100)
)
ORGANIZATION EXTERNAL
( TYPE ORACLE_LOADER
DEFAULT DIRECTORY "SCPO_EXT_DATA"
ACCESS PARAMETERS
( RECORDS DELIMITED BY NEWLINE
FIELDS TERMINATED BY ','
MISSING FIELD VALUES ARE NULL
(id varchar2(100),
name varchar2(100),
dob varchar2(100)
)
)
LOCATION
( 'xyz_aldrin.csv'
)
);
PS:
This error however doesn't occur if the varchar2(100) is changed to char(100):
MISSING FIELD VALUES ARE NULL
(id char(100),
name char(100),
dob char(100)
)

It is important to distinguish between oracle internal data types specified on the table, and the external data types specified in the access parameters for the external table (control file for sqlldr). Read the manual again with that in mind. It should become clear. CHAR is allowed in SQL loader whereas VARCHAR2 is not

Related

Oracle 11g _ ORA-00904 error message with Insert statement

I created a simple table:
CREATE TABLE "ADVUPGRD"."GL_CAMPUSEMAILS"
("Campus" VARCHAR2(2 CHAR), "SEND_TO" VARCHAR2(60 CHAR), "SEND_CC"
VARCHAR2(250 CHAR), "SEND_BCC" VARCHAR2(60 CHAR))
The table got created, I can do select * from gl_campusemails and it gets me a blank row since I have not populated this table yet.
When I'm populating the table I'm using this:
INSERT INTO GL_CAMPUSEMAILS (Campus, Send_To, Send_CC, Send_BCC)
VALUES('CP', 'as#gmail.com', 'test#yahoo.com', 'test2#gmail.com');
but I got this error message:
Error starting at line : 8 in command -
INSERT INTO GL_CAMPUSEMAILS (Campus, Send_To, Send_CC, Send_BCC)
VALUES('CP', 'as#gmail.com', 'test#yahoo.com', 'test2#gmail.com')
Error at Command Line : 8 Column : 56
Error report -
SQL Error: ORA-00904: "SEND_BCC": invalid identifier
00904. 00000 - "%s: invalid identifier"
*Cause:
*Action:
I googled and found a lot of posting but they're mostly related to the use of reserved words in the select statement.
I don't think the columns I used in here belong to any reserved words.What did I do wrong in here
If you use double quotes while creating the table, the column names are created exactly as you typed, case sensitive; thus, you insert should be:
INSERT INTO GL_CAMPUSEMAILS(
"Campus",
"SEND_TO",
"SEND_CC",
"SEND_BCC"
)
VALUES (
'CP',
'as#gmail.com',
'test#yahoo.com',
'test2#gmail.com'
);
If you create the table with no quotes, this will work fine
CREATE TABLE GL_CAMPUSEMAILS
(
Campus VARCHAR2(2 CHAR),
SEND_TO VARCHAR2(60 CHAR),
SEND_CC VARCHAR2(250 CHAR),
SEND_BCC VARCHAR2(60 CHAR)
);
INSERT INTO GL_CAMPUSEMAILS(
Campus,
SEND_TO,
SEND_CC,
SEND_BCC
)
VALUES (
'CP',
'as#gmail.com',
'test#yahoo.com',
'test2#gmail.com'
);
Notice that not using double quotes, Oracle will consider all the objects with upper case names; so, for example, "CAMPUS", campus, CaMpUs will work, while "campus" will not

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')
)

I'm trying to create External table but I got stuck

I'm able to create table successfully but whenever I'm fetching external table I got error
create table xyz ( t1 varchar2(20),t2 varchar(10),t3 varchar(10),t4 date,t5 varchar(10),t6 varchar(10),t7 varchar(10),t8 varchar(20),t9 varchar(25),t10 varchar(60),t11 varchar(60))
ORGANIZATION EXTERNAL (
TYPE ORACLE_LOADER
DEFAULT DIRECTORY DE_DUBFILE
ACCESS PARAMETERS
(
RECORDS DELIMITED BY NEWLINE
BADFILE DE_DUBFILE: 'xyz.bad'
DISCARDFILE DE_DUBFILE: 'xyz.dis'
LOGFILE DE_DUBFILE: 'xyz.log'
FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"'
MISSING FIELD VALUES ARE NULL
(
t1,t2,t3,t4 date "YYYYMMDD",t5,t6,t7,t8,t9,
t10 "ORA_HASH(:t1||:t2||:t3 )",
t11 "ORA_HASH(:t6||:t8||:t9 )"
)
)
LOCATION (DE_DUBFILE:'ZZZ'));
I'm getting below error
ORA-29400: data cartridge error
KUP-00554: error encountered while parsing access parameters
KUP-01005: syntax error: found "double-quoted-string": expecting one of: "binary_double, binary_float, comma, char, date, defaultif, decimal, double, float, integer, (, no, nullif, oracle_date, oracle_number, position, raw, recnum, ), unsigned, varrawc, varchar, varraw, varcharc, zoned"
KUP-01007: at line 11 column 57
Script Terminated on line 26.
It seems to me that "ORA_HASH(:t1||:t2||:t3 )" can't be processed.
Try to load without them (t10 and t11) and generate these fields after all.

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.

Resources