Trying to Create External Table in 8i
hi Grus,
We are still on 8.1.7 version. And oracle 8i doesn't support the External table feature. last week i found a very useful documentation to access an operating system file from SQPLUS. but i am having a small problem, may be one of you guys can give me a tip if i am doing something wrong. below is the story.
1) i created a object type with 4 attributes in database.
CREATE OR REPLACE TYPE Artist_Row_Type AS OBJECT
ARTIST_ID NUMBER(10),
LASTNAME VARCHAR2(255),
FIRSTNAME VARCHAR2(255),
LASTNAMEFIRSTNAME VARCHAR2(255)
2) Then i created a collection type of obove object type.
CREATE OR REPLACE TYPE artist_tab_type AS TABLE OF artist_row_type;
3) Created a function
CREATE OR REPLACE FUNCTION Get_Artist
RETURN artist_tab_type
IS
artist_tab artist_tab_type := artist_tab_type ();
l_file UTL_FILE.file_type;
l_text VARCHAR2 (2000);
l_orig_str VARCHAR2 (2000);
cnt PLS_INTEGER := 0;
l_start_pos INTEGER := 1;
l_end_pos INTEGER := 1;
TYPE xyz IS TABLE OF VARCHAR2 (2000)
INDEX BY BINARY_INTEGER;
var xyz;
BEGIN
l_file := UTL_FILE.fopen ('/export/home/taskmgr/SA/DAT', 'artist.dat', 'r');
BEGIN
FOR i IN 1 .. 4
LOOP
var (i) := ' ';
END LOOP;
LOOP
UTL_FILE.get_line (l_file, l_text);
FOR i IN var.FIRST .. var.LAST
LOOP
IF l_end_pos <> 0
THEN
l_end_pos := INSTR (l_text, '|', l_start_pos);
IF l_end_pos = 0
THEN
var (i) := l_text;
END IF;
l_orig_str := l_text;
l_text := SUBSTR (l_text, INSTR (l_text, '|') + 1);
IF l_end_pos <> 0
THEN
var (i) := SUBSTR (l_orig_str, 1, INSTR (l_orig_str, '|') - 1);
END IF;
END IF;
END LOOP;
artist_tab.EXTEND;
artist_tab (artist_tab.LAST) := artist_row_type (var (1), var (2), var (3), var (4));
END LOOP;
EXCEPTION
WHEN NO_DATA_FOUND
THEN
NULL;
END;
UTL_FILE.fclose (l_file);
RETURN artist_tab;
END;
suppoose first line in a external file is '14522|||Lessig|||Minna|||Lessig, Minna'
and when i execute the following query.
select * FROM TABLE(Cast(Get_Artist() AS artist_tab_Type));
i get the following result.
ARTIST_ID LASTNAME FIRSTNAME LASTNAMEFIRSTNAME
14522 Lessig
while i should get the following result
ARTIST_ID LASTNAME FIRSTNAME LASTNAMEFIRSTNAME
14522 Lessing Minna Lessig, Minna
is any body can have look in my function code if something is missing please let me know.
Thanks
Asif
The data in your file is separated by ||| (three pipes) but your routine is using | (one pipe) as its token.
Cheers, APC
Similar Messages
-
Error while creating external table
Hi i tried to create external table. The table is created but while selecting that table it is throwing below errors
ORA-29913: error in executing ODCIEXTTABLEOPEN callout
ORA-29400: data cartridge error
KUP-04040: file Countries1.txt in EXT_TABLES not found
ORA-06512: at "SYS.ORACLE_LOADER", line 19I've created temp directory in window under oracle directory " C:\oracle\product\10.2.0\temp"
In the temp directory i've a text file countries1.txt
the text file has the below information
ENG,England,English
SCO,Scotland,English
IRE,Ireland,English
WAL,Wales,WelshI've connected to system user and created one directory and granted the read and write permissions to user SCOTT.
SQL> create or replace directory ext_tables as 'C:\oracle\product\10.2.0\temp\';
Directory created.
SQL> grant read,write on directory ext_tables to scott;
Grant succeeded.The creation of external table query is
CREATE TABLE countries_ext (
country_code VARCHAR2(5),
country_name VARCHAR2(50),
country_language VARCHAR2(50)
ORGANIZATION EXTERNAL (
TYPE ORACLE_LOADER
DEFAULT DIRECTORY ext_tables
ACCESS PARAMETERS (
RECORDS DELIMITED BY NEWLINE
FIELDS TERMINATED BY ','
MISSING FIELD VALUES ARE NULL
country_code CHAR(5),
country_name CHAR(50),
country_language CHAR(50)
LOCATION ('Countries1.txt')
PARALLEL 5
REJECT LIMIT UNLIMITED;And the error is
SQL> select *from countries_ext;
select *from countries_ext
ERROR at line 1:
ORA-29913: error in executing ODCIEXTTABLEOPEN callout
ORA-29400: data cartridge error
KUP-04040: file Countries1.txt in EXT_TABLES not found
ORA-06512: at "SYS.ORACLE_LOADER", line 19
SQL> Please help me in thisYou are missing something. Most probably the file does not exists in your specified path. This is working in my 10.2.0.3
Step1: Check the file is actually there.
C:\oracle\product\10.2.0>mkdir temp
C:\oracle\product\10.2.0>cd temp
C:\oracle\product\10.2.0\temp>dir
Volume in drive C is C_Drive
Volume Serial Number is 8A93-1441
Directory of C:\oracle\product\10.2.0\temp
07/30/2011 12:00 PM <DIR> .
07/30/2011 12:00 PM <DIR> ..
07/30/2011 12:00 PM 79 countries1.txt
1 File(s) 79 bytes
2 Dir(s) 50,110,582,784 bytes free
C:\oracle\product\10.2.0\temp>type countries1.txt
ENG,England,English
SCO,Scotland,English
IRE,Ireland,English
WAL,Wales,Welsh
C:\oracle\product\10.2.0\temp>Step 2: Creating the directory object.
SQL> show user
USER is "SYS"
SQL> SELECT * FROM v$version;
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
PL/SQL Release 10.2.0.3.0 - Production
CORE 10.2.0.3.0 Production
TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
NLSRTL Version 10.2.0.3.0 - Production
SQL> create or replace directory ext_tables as 'C:\oracle\product\10.2.0\temp';
Directory created.
SQL> grant read,write on directory ext_tables to scott;
Grant succeeded.
SQL>Step 3: Table definition.
C:\>sqlplus scott@orclsb/tiger
SQL*Plus: Release 10.1.0.4.2 - Production on Sat Jul 30 12:04:24 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> CREATE TABLE countries_ext (
2 country_code VARCHAR2(5),
3 country_name VARCHAR2(50),
4 country_language VARCHAR2(50)
5 )
6 ORGANIZATION EXTERNAL (
7 TYPE ORACLE_LOADER
8 DEFAULT DIRECTORY ext_tables
9 ACCESS PARAMETERS (
10 RECORDS DELIMITED BY NEWLINE
11 FIELDS TERMINATED BY ','
12 MISSING FIELD VALUES ARE NULL
13 (
14 country_code CHAR(5),
15 country_name CHAR(50),
16 country_language CHAR(50)
17 )
18 )
19 LOCATION ('Countries1.txt')
20 )
21 PARALLEL 5
22 REJECT LIMIT UNLIMITED;
Table created.
SQL> SELECT * FROM countries_ext;
COUNT COUNTRY_NAME
COUNTRY_LANGUAGE
ENG England
English
SCO Scotland
English
IRE Ireland
English
COUNT COUNTRY_NAME
COUNTRY_LANGUAGE
WAL Wales
Welsh -
Can i create External Table dynamically
Hi,
Is it possible to create External Table dynamically ?
I want to use the following dynamically to create External Table.
1) fields
2) field position
3) file location
ThanksThe answer shouldn't be very different of already given answers in your Can i create external table dynamically? of the last month, is it ?
And question is still same : why wanted such thing ?
Nicolas. -
Create external table in procedure
i have a PL/SQL Block [ well i'm not created procedure still]
/* Formatted on 2011/01/05 11:53 (Formatter Plus v4.8.8) */
DECLARE
-- create header
p_formula_no VARCHAR2 (200);
p_formula_vers NUMBER;
p_formula_desc VARCHAR2 (200);
p_formula_desc2 VARCHAR2 (200);
p_formula_class VARCHAR2 (200);
p_owner_organization_id NUMBER;
p_owner_id NUMBER;
p_formula_type NUMBER;
p_scale_type NUMBER;
p_text_code NUMBER;
p_last_update_date DATE;
p_auto_product_calc VARCHAR2 (200);
x_formula_id NUMBER;
x_return_code VARCHAR2 (200);
x_error_msg VARCHAR2 (200);
formula_id NUMBER;
-- update header
p_formula_id NUMBER;
p_formula_status VARCHAR2 (200);
p_user_id NUMBER;
p_last_update_date_orig DATE;
p_formulaline_id NUMBER;
p_line_type NUMBER;
p_line_no NUMBER;
p_item_id NUMBER;
p_item_no VARCHAR2 (200);
p_revision VARCHAR2 (200);
p_qty NUMBER;
p_item_um VARCHAR2 (200);
p_release_type NUMBER;
p_scrap_factor NUMBER;
p_cost_alloc NUMBER;
p_phantom_type NUMBER;
p_rework_type NUMBER;
p_tp_formula_id NUMBER;
p_iaformula_id NUMBER;
p_scale_uom VARCHAR2 (200);
p_contribute_step_qty_ind VARCHAR2 (200);
p_contribute_yield_ind VARCHAR2 (200);
p_scale_multiple NUMBER;
p_scale_rounding_variance NUMBER;
p_rounding_direction NUMBER;
p_by_product_type VARCHAR2 (200);
p_prod_percent NUMBER;
-- create header and update header cursors
CURSOR c1
IS
SELECT DISTINCT formula_no, formula_ver, formula_desc, formula_class,
owner_header
FROM api_formula;
-- for product cursors
CURSOR c2
IS
SELECT *
FROM api_formula
WHERE line_type = 1;
-- for ingredient cursors
CURSOR c3
IS
SELECT *
FROM api_formula
WHERE line_type = -1;
hdr c1%ROWTYPE;
prod c2%ROWTYPE;
ing c3%ROWTYPE;
BEGIN
-- for create and update header
OPEN c1;
FETCH c1
INTO hdr;
WHILE c1%FOUND
LOOP
p_formula_no := hdr.formula_no;
p_formula_vers := hdr.formula_ver;
p_formula_desc := hdr.formula_desc;
p_formula_desc2 := NULL;
p_formula_class := hdr.formula_class;
p_owner_organization_id := 327;
p_owner_id := 1298;
p_formula_type := 0;
p_scale_type := 0;
p_text_code := 0;
p_last_update_date := SYSDATE;
p_auto_product_calc := 'Y';
x_formula_id := NULL;
x_return_code := NULL;
x_error_msg := NULL;
apps.gmd_formula_designer_pkg_cust.create_formula_header
(p_formula_no,
p_formula_vers,
p_formula_desc,
p_formula_desc2,
p_formula_class,
p_owner_organization_id,
p_owner_id,
p_formula_type,
p_scale_type,
p_text_code,
p_last_update_date,
p_auto_product_calc,
x_formula_id,
x_return_code,
x_error_msg
COMMIT;
SELECT formula_id
INTO formula_id
FROM fm_form_mst_b
WHERE formula_no = hdr.formula_no;
p_formula_id := formula_id;
p_formula_no := NULL;
p_formula_vers := NULL;
p_formula_desc := NULL;
p_formula_desc2 := NULL;
p_formula_status := 700;
p_formula_class := NULL;
p_owner_organization_id := 327;
p_owner_id := 1298;
p_formula_type := 0;
p_scale_type := 0;
p_text_code := NULL;
p_last_update_date := SYSDATE;
p_user_id := 1298;
p_last_update_date_orig := SYSDATE;
p_auto_product_calc := 'Y';
x_return_code := NULL;
x_error_msg := NULL;
apps.gmd_formula_designer_pkg_cust.update_formula_header
(p_formula_id,
p_formula_no,
p_formula_vers,
p_formula_desc,
p_formula_desc2,
p_formula_status,
p_formula_class,
p_owner_organization_id,
p_owner_id,
p_formula_type,
p_scale_type,
p_text_code,
p_last_update_date,
p_user_id,
p_last_update_date_orig,
p_auto_product_calc,
x_return_code,
x_error_msg
DBMS_OUTPUT.put_line (x_return_code);
DBMS_OUTPUT.put_line (x_error_msg);
COMMIT;
-- for PROD
OPEN c2;
FETCH c2
INTO prod;
WHILE c2%FOUND
LOOP
p_formula_id := formula_id;
p_formulaline_id := NULL;
p_line_type := 1;
p_line_no := prod.line_no;
p_item_id := prod.item_id;
p_item_no := prod.item_name;
p_revision := NULL;
p_qty := prod.qty;
p_item_um := prod.uom;
p_release_type := 0;
p_scrap_factor := 0;
p_scale_type := 1;
p_cost_alloc := 1;
p_phantom_type := 0;
p_rework_type := NULL;
p_text_code := NULL;
p_tp_formula_id := NULL;
p_iaformula_id := NULL;
p_scale_uom := NULL;
p_contribute_step_qty_ind := NULL;
p_contribute_yield_ind := NULL;
p_scale_multiple := NULL;
p_scale_rounding_variance := NULL;
p_rounding_direction := NULL;
p_by_product_type := NULL;
p_last_update_date := SYSDATE;
p_user_id := 1298;
p_prod_percent := NULL;
x_return_code := NULL;
x_error_msg := NULL;
apps.gmd_formula_designer_pkg.insert_formula_detail
(p_formula_id,
p_formulaline_id,
p_line_type,
p_line_no,
p_item_id,
p_item_no,
p_revision,
p_qty,
p_item_um,
p_release_type,
p_scrap_factor,
p_scale_type,
p_cost_alloc,
p_phantom_type,
p_rework_type,
p_text_code,
p_tp_formula_id,
p_iaformula_id,
p_scale_uom,
p_contribute_step_qty_ind,
p_contribute_yield_ind,
p_scale_multiple,
p_scale_rounding_variance,
p_rounding_direction,
p_by_product_type,
p_last_update_date,
p_user_id,
p_prod_percent,
x_return_code,
x_error_msg
DBMS_OUTPUT.put_line (x_return_code);
DBMS_OUTPUT.put_line (x_error_msg);
COMMIT;
FETCH c2
INTO prod;
END LOOP;
-- for ing
OPEN c3;
FETCH c3
INTO ing;
WHILE c3%FOUND
LOOP
p_formula_id := formula_id;
p_formulaline_id := NULL;
p_line_type := -1;
p_line_no := ing.line_no;
p_item_id := ing.item_id;
p_item_no := ing.item_name;
p_revision := NULL;
p_qty := ing.qty;
p_item_um := ing.uom;
p_release_type := 0;
p_scrap_factor := 0;
p_scale_type := 1;
p_cost_alloc := 1;
p_phantom_type := 0;
p_rework_type := NULL;
p_text_code := NULL;
p_tp_formula_id := NULL;
p_iaformula_id := NULL;
p_scale_uom := NULL;
p_contribute_step_qty_ind := NULL;
p_contribute_yield_ind := NULL;
p_scale_multiple := NULL;
p_scale_rounding_variance := NULL;
p_rounding_direction := NULL;
p_by_product_type := NULL;
p_last_update_date := SYSDATE;
p_user_id := 1298;
p_prod_percent := NULL;
x_return_code := NULL;
x_error_msg := NULL;
apps.gmd_formula_designer_pkg.insert_formula_detail
(p_formula_id,
p_formulaline_id,
p_line_type,
p_line_no,
p_item_id,
p_item_no,
p_revision,
p_qty,
p_item_um,
p_release_type,
p_scrap_factor,
p_scale_type,
p_cost_alloc,
p_phantom_type,
p_rework_type,
p_text_code,
p_tp_formula_id,
p_iaformula_id,
p_scale_uom,
p_contribute_step_qty_ind,
p_contribute_yield_ind,
p_scale_multiple,
p_scale_rounding_variance,
p_rounding_direction,
p_by_product_type,
p_last_update_date,
p_user_id,
p_prod_percent,
x_return_code,
x_error_msg
DBMS_OUTPUT.put_line (x_return_code);
DBMS_OUTPUT.put_line (x_error_msg);
COMMIT;
FETCH c3
INTO ing;
END LOOP;
FETCH c1
INTO hdr;
END LOOP;
DBMS_OUTPUT.put_line (p_formula_id);
DBMS_OUTPUT.put_line (x_return_code);
DBMS_OUTPUT.put_line (x_error_msg);
END;in this PL/SQL Block i'm used external table which is "API_FORMULA"
the coding is
create table api_formula
( FORMULA_NO varchar2(2000),
FORMULA_VER NUMBER,
FORMULA_DESC varchar2(2000),
FORMULA_CLASS varchar2(2000),
ORG NUMBER,
OWNER_HEADER NUMBER,
LINE_TYPE NUMBER,
LINE_NO NUMBER,
ITEM_ID NUMBER,
ITEM_NAME VARCHAR2(2000),
QTY NUMBER,
UOM VARCHAR2(200),
SCRAP_FAC NUMBER,
SCRAP_TYPE NUMBER,
UPDATE_DATE date,
OWNER_LINE NUMBER,
testt char(2)/*,
future_use varchar2(200)*/
organization external
( default directory ZAFAR
access parameters
( records delimited by newline
fields terminated by ','
location ('HEADER.csv')
reject limit 100
;i want this create external table statment in my Pl/SQL Block and when all the execution is complete then drop the table
how it is possible??
regard
chintoouser11156570 wrote:
@BluShadow
ok .. i want to delete all rows from table in the end when execute this PL/SQLdelete all rows from what table?
If you're referring to the external table, it's a file on the filesystem, you don't delete rows from it, you just replace/overwrite/delete the file as and when necessary.
blushadow how i crate a reliable code.. can u suggest me?Basics of transactions... you commit when a business rule/process is complete, not for every little technical thing your code does. In your case I would expect a single commit at the end of the code.
I don't have your tables, data or know what the code is supposed to be achieving, but you can bet your bottom dollar that if you're nesting cursor loops within each other then the code is running much slower than if you generated the data from a single SQL statement/cursor. I certainly have no clue what those procedure calls are doing, but it looks like they're using a load of OUT parameters. Are they user defined procedures or something that's part of e.g. Oracle Apps? If they're user defined I would consider redesigning all the code to use functions and pass back a structured data type with the required data. -
HELP!! just finished a 20pages report and when trying to create the table of contest I lost EVERYTHING... there is nothing left of my work. WHY????
Hi Peter,
Yes I'am in 5.2, I did mention it right after.
This is wonderful Peter, great advice. I got to have my latest version before I created my table of contents.
In Pages > Menu > File > Revert
and see what you get.
Peter
Thank you so much!!
Have a wonderful day -
Creating external table - from a file with multiple field separators
I need to create an external table from a flat file containing multiple field separators (",", ";" and "|").
Is there any way to specifiy this in the CREATE TABLE (external) statement?
FIELDS TERMINATED BY "," -- Somehow list more than just comma here?
We receive the file from a vendor every week. I am trying to set up a process for some non-technical users, and I want to keep this process transparent to them and not require them to load the data into Oracle.
I'd appreciate your help!scott@ORA92> CREATE OR REPLACE DIRECTORY my_dir AS 'c:\oracle'
2 /
Directory created.
scott@ORA92> CREATE TABLE external_table
2 (COL1 NUMBER,
3 COL2 VARCHAR2(6),
4 COL3 VARCHAR2(6),
5 COL4 VARCHAR2(6),
6 COL5 VARCHAR2(6))
7 ORGANIZATION external
8 (TYPE oracle_loader
9 DEFAULT DIRECTORY my_dir
10 ACCESS PARAMETERS
11 (FIELDS
12 (COL1 CHAR(255)
13 TERMINATED BY "|",
14 COL2 CHAR(255)
15 TERMINATED BY ",",
16 COL3 CHAR(255)
17 TERMINATED BY ";",
18 COL4 CHAR(255)
19 TERMINATED BY ",",
20 COL5 CHAR(255)
21 TERMINATED BY ","))
22 location ('flat_file.txt'))
23 /
Table created.
scott@ORA92> select * from external_table
2 /
COL1 COL2 COL3 COL4 COL5
1 Field1 Field2 Field3 Field4
2 Field1 Field2 Field3 Field4
scott@ORA92> -
Create external table on a CSV file with a variable number of delimiters
Hi experts,
I was wondering what the best approach for the following issue.
I'm trying to create an external table on a file which has in each record (on a new line 'RECORDS DELIMITED BY NEWLINE') a variabel number of delimiters. By example my delimiter is a comma , in the first record I have 100 comma's in the second only 60, the next 80 etc.etc.
Is there a way to create a external table on this file?
Thanks in advance.alter the source is no option, unfortunalty. But is suggested there would be a sensible workway to handle it. An to solve it I want to pivot i, but first I think I need to have the file in Oracle through a external table.
Edited by: Jonathan Wisgerhof on Mar 31, 2009 12:21 PM -
Interactive report errors when trying to query external table.
I'm trying to create an interactive report against an external table and getting the following error. I see a note in metalink the describes its cause, but I doesn't seem to apply here.
Query cannot be parsed, please check the syntax of your query. (ORA-06550: line 2, column 17: PLS-00302: component 'ODCIOBJECTLIST' must be declared ORA-06550: line 2, column 13: PL/SQL: Item ignored ORA-06550: line 4, column 18: PLS-00302: component 'ORACLE_LOADER' must be declared ORA-06550: line 4, column 6: PL/SQL: Statement ignored ORA-06550: line 5, column 12: PLS-00320: the declaration of the type of this expression is incomplete or malformed ORA-06550: line 5, column 6: PL/SQL: Statement ignored)
Metalink Note:437896.1 identifies this same error related to external tables. It says the cause is an object named 'sys' that exist in the user's schema and must be removed. I checked dba_objects and there is no object named 'sys'Please ignore thread - operator error. There was an object named sys.
-
hi everyone,
I have a problems :
I have created a flat file through flat file module from a text file.
i've done it successfully,
then i create an external table through external table module for the same
flat file , went successfully,
then velidation went successfull,
and i carried out deployement for the same, that also done successfully.
but when i tried to check the database through SQL-Plus :
i came across with the following error :
SQL> CONNECT TARGET_SCHEMA/TARGET_SCHEMA
Connected.
SQL> SELECT * FROM CUMMINS_EXT;
SELECT * FROM CUMMINS_EXT
ERROR at line 1:
ORA-29913: error in executing ODCIEXTTABLEOPEN callout
ORA-29400: data cartridge error
KUP-04040: file Cumminsparts.txt in TARGET_LOC_CUMMINS_LOC not found
ORA-06512: at "SYS.ORACLE_LOADER", line 19
ORA-06512: at line 1
Please someone guide me to resolve this prob.
Thanking you,Thanks to you all,
I had created a new file location in OWB to create
a flat file module but I dont know somewhere
i missed something while creating the new file location
that is why it was not loading data inspite of deploy successed ,
but when i put the same file to one of existing file location
and i deployed it and i got the data.
now i am exploring the existing file location for what was that
i missed during creation of new location.
Guys i am new to OWB so i dont know how to go about , if you have any
easy way to get hands on OWB, please let me know
Once again thanks everybody. -
I'm trying to map a trace file to an external table' but I'm getting "missing keyword" error.
set verify off
create or replace directory 'TRACE_DIR' as '/db_home/oracle/product/diag/rdbms/test/dtms_t/trace';
column id new_value os_user;
SELECT sys_context('USERENV', 'OS_USER') id FROM DUAL;
BEGIN
EXECUTE IMMEDIATE 'alter session set tracefile_identifier = &os_user' ;
END;
column tracefile_loc new_value tracefile
select SUBSTR(tracefile_loc,INSTR(tracefile_loc,'/',-1)+1) tracefile_loc
from
( select value ||'/'||(select instance_name from v$instance) ||'_ora_'||
(select spid||case when traceid is not null then '_'||traceid else null end
from v$process where addr = (select paddr from v$session
where sid = (select sid from v$mystat
where rownum = 1
) || '.trc' tracefile_loc
from v$parameter where name = 'user_dump_dest'
jbrock@ddtms_t> CREATE TABLE trace_ext
2 (line varchar2(80)
3 )
4 ORGANIZATION EXTERNAL
5 (
6 TYPE ORACLE_LOADER
7 DEFAULT DIRECTORY trace_dir
8 ACCESS PARAMETERS
9 (
10 records delimited by newline
11 missing field values are null
12 ( line
13 )
14 )
15 LOCATION (&&tracefile)
16 )
17 REJECT LIMIT UNLIMITED;
LOCATION (ddtms_t_ora_9101_JBROCK.trc)
ERROR at line 15:
ORA-00905: missing keywordHi,
jimmyb wrote:
... jbrock@ddtms_t> CREATE TABLE trace_ext
2 (line varchar2(80)
3 )
4 ORGANIZATION EXTERNAL
5 (
6 TYPE ORACLE_LOADER
7 DEFAULT DIRECTORY trace_dir
8 ACCESS PARAMETERS
9 (
10 records delimited by newline
11 missing field values are null
12 ( line
13 )
14 )
15 LOCATION (&&tracefile)
16 )
17 REJECT LIMIT UNLIMITED;
LOCATION (ddtms_t_ora_9101_JBROCK.trc)
ERROR at line 15:
ORA-00905: missing keyword
Doesn't the location have to be in single-qutoes? For line 15, try
LOCATION ('&&tracefile') -
Syntax Error, while Creating External Table
Hi,
Can anyone tell this Syntax is correct or not. And how it look like:
CREATE TABLE emp_load (T_DATE DATE NOT NULL,
T_NO DOUBLE PRECISION,
T_TYPE CHAR(1),
T_CO VARCHAR(30),
T_CONTRACT DOUBLE PRECISION,
T_PARTY VARCHAR(15),
T_BILL_NO DOUBLE PRECISION,
T_BILL_DATE DATE,
T_QTY DOUBLE PRECISION,
T_RATE DOUBLE PRECISION,
T_BKG DOUBLE PRECISION NOT NULL,
T_TAX DOUBLE PRECISION,
T_OTHER DOUBLE PRECISION,
T_DIV DOUBLE PRECISION,
T_STAMPS DOUBLE PRECISION,
T_DC_NO DOUBLE PRECISION,
T_SPOT CHAR(2),
T_CITY VARCHAR(3),
T_ORDER DOUBLE PRECISION,
T_TRADE DOUBLE PRECISION,
T_TIME DATE,
T_FORM CHAR(1),
HEADER VARCHAR(2),
T_DC_DATE DATE,
T_POD VARCHAR(30),
T_POD_DATE DATE,
T_SET INTEGER,
T_MARGIN DOUBLE PRECISION NOT NULL WITH DEFAULT,
T_MKT_TYPE VARCHAR(3) NOT NULL,
T_MEMBER_CODE VARCHAR(15),
T_EXIM SMALLINT,
T_P VARCHAR(15),
T_C VARCHAR(30),
T_TERM VARCHAR(8),
T_CUST VARCHAR(12),
T_SUBBKG DOUBLE PRECISION,
T_BILL_TYPE VARCHAR(1),
T_OPN_CLS DOUBLE PRECISION,
T_AUCTION DOUBLE PRECISION,
T_BRANCH VARCHAR(8),
T_UNQID VARCHAR(20),
T_SQ SMALLINT,
T_CBKG DOUBLE PRECISION,
T_COTHER DOUBLE PRECISION,
T_MOD DATE,
T_ORIG_CUST VARCHAR(20),
T_TOT DOUBLE PRECISION,
T_FIRM SMALLINT,
T_ORDER_TIME DATE,
T_NON_MT SMALLINT)
ORGANIZATION EXTERNAL (TYPE ORACLE_LOADER DEFAULT DIRECTORY ext_tab_dir
ACCESS PARAMETERS (RECORDS FIXED 62 FIELDS (T_DATE DATE NOT NULL,
T_NO DOUBLE PRECISION,
T_TYPE CHAR(1),
T_CO VARCHAR(30),
T_CONTRACT DOUBLE PRECISION,
T_PARTY VARCHAR(15),
T_BILL_NO DOUBLE PRECISION,
T_BILL_DATE DATE,
T_QTY DOUBLE PRECISION,
T_RATE DOUBLE PRECISION,
T_BKG DOUBLE PRECISION NOT NULL,
T_TAX DOUBLE PRECISION,
T_OTHER DOUBLE PRECISION,
T_DIV DOUBLE PRECISION,
T_STAMPS DOUBLE PRECISION,
T_DC_NO DOUBLE PRECISION,
T_SPOT CHAR(2),
T_CITY VARCHAR(3),
T_ORDER DOUBLE PRECISION,
T_TRADE DOUBLE PRECISION,
T_TIME DATE,
T_FORM CHAR(1),
HEADER VARCHAR(2),
T_DC_DATE DATE,
T_POD VARCHAR(30),
T_POD_DATE DATE,
T_SET INTEGER,
T_MARGIN DOUBLE PRECISION NOT NULL WITH DEFAULT,
T_MKT_TYPE VARCHAR(3) NOT NULL,
T_MEMBER_CODE VARCHAR(15),
T_EXIM SMALLINT,
T_P VARCHAR(15),
T_C VARCHAR(30),
T_TERM VARCHAR(8),
T_CUST VARCHAR(12),
T_SUBBKG DOUBLE PRECISION,
T_BILL_TYPE VARCHAR(1),
T_OPN_CLS DOUBLE PRECISION,
T_AUCTION DOUBLE PRECISION,
T_BRANCH VARCHAR(8),
T_UNQID VARCHAR(20),
T_SQ SMALLINT,
T_CBKG DOUBLE PRECISION,
T_COTHER DOUBLE PRECISION,
T_MOD DATE,
T_ORIG_CUST VARCHAR(20),
T_TOT DOUBLE PRECISION,
T_FIRM SMALLINT,
T_ORDER_TIME DATE,
T_NON_MT SMALLINT))
LOCATION ('BR271107.DAT'))
Error at Command Line:28 Column:40
Error report:
SQL Error: ORA-00905: missing keyword
00905. 00000 - "missing keyword"
Thank u..!
RaviWhere can we find that directory in the server. You have to provide for it's existence.
So you must create C:/Oracle on the server or have your ext_tab_dir point to some existing directory on the server (better if dedicated to external tables for not creating confusion)
You must also see to have read and write OS rights and have granted read (and write) privileges on directory ext_tab_dir to your_user_name
Regards
Etbin
If you can use utl_file try to use utl_file_dir as your ext_tab_dir to perform the test => copy your file to the directory your utl_file_dir is pointing to and do select * from test
Message was edited by: Etbin
user596003 -
Error while trying to create a table in SQL
I am fairly new to Visual Studio. I am using the Visual Studio 2012. So I had to create a project in MVC. I made the Views and the controllers. I did add a Database from, _AppDate->Add->New Item-> SQL Server Compact 4.0 Local Database.
Now that I am trying to create a new table from the Server Explorer window. Right click on Tables->Create Table. I'm getting the following error.
"Could not load file or assembly 'Microsoft.SqlServer.SqlTDiagM, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified."
I have no idea how to resolve this. Any help in this matter would be highly appreciated.
Thank You.Hi Charvi,
What type of database/application are you trying to connect? Are you getting any error message?
Missing primary key message is just a warning and is not related to the issue.
Cheers
Mohan -
Error in creating External Table
I am following the following procedure to create an external table,but somehow i am not getting success.Can anyone pls explain the error?
CREATE OR REPLACE DIRECTORY TEST_DIR AS 'C:\TEST'
Directory created.
GRANT READ,WRITE ON DIRECTORY TEST_DIR TO PUBLIC
Grant succeeded.
CREATE TABLE external_table
(empno NUMBER(4),
ename VARCHAR2(10),
job VARCHAR2(9),
mgr NUMBER(4),
hiredate DATE,
sal NUMBER(7, 2),
comm NUMBER(7, 2),
deptno NUMBER(2))
ORGANIZATION EXTERNAL
(TYPE ORACLE_LOADER
DEFAULT DIRECTORY TEST_DIR
ACCESS PARAMETERS
(RECORDS DELIMITED BY NEWLINE
BADFILE 'TEST_DIR':'emp.bad'
LOGFILE 'TEST_DIR':'emp.log'
FIELDS TERMINATED BY ',')
LOCATION ('emp.csv'))
Table created.
The file emp.csv is located in TEST_DIR.
SELECT * FROM EXTERNAL_TABLE
ERROR at line 1:
ORA-29913: error in executing ODCIEXTTABLEOPEN callout
ORA-29400: data cartridge error
KUP-04063: unable to open log file emp.log
OS error The system cannot find the file specified.
ORA-06512: at "SYS.ORACLE_LOADER", line 19
-MSquote from the docs:
"Note that READ or WRITE permission to a directory object means only that the Oracle database will read or write that file on your behalf. You are not given direct access to those files outside of the Oracle database unless you have the appropriate operating system privileges. Similarly, the Oracle database requires permission from the operating system to read and write files in the directories."
http://www.di.unipi.it/~ghelli/didattica/bdl/B19306_01/server.102/b14215/et_concepts.htm -
Need help in Creating External Tables
Hi All,
I have a flat file containing numberic data, CLOB data, and also date columns data. I have to load this flat file data into staging server table using External tables. I have to write a stored procedure in such way creating exteranl tables dynamically. My question or need help from you people is that how to define the external table to load the CLOB data from flat file.
Thanks,
SankarThe LOCATION clause of an external table specifies the file or files to be read when the table is queried. You can change it to refer to different files without dropping and recreating the table and invalidating all dependent code.
Regarding DBMS_SQL, yes you can do it the hard way if you prefer.
Good point about CLOB columns in external tables. Quite possibly they are not supported, but I would have to check the manuals and try some examples. -
ORA-00942 when creating external table under 10g with AQ
I have an application that runs with AQ. The front-end queues up batch-type
tasks in a queue. When one particular kind of message is dequeued, it
initiates a data load. That load requires the creation of an external
table.
The schema in question is owned by user BL (bulkload). The queue
is owned by BLB (bulkload batch), primarily to simplify some of the
rules needed by the resource manager in order to limit the total CPU
a batch process can consume. The BLB user has full access to the
BL schema, along with the following rights:
CREATE TYPE
CREATE TABLE
CREATE SEQUENCE
CREATE PROCEDURE
CREATE VIEW
CREATE SYNONYM
CREATE SEQUENCE
ALTER SESSION
CREATE SESSION
QUERY REWRITE
CREATE ANY CONTEXT
EXECUTE_CATALOG_ROLE
CREATE MATERIALIZED VIEW
CREATE ANY DIRECTORY
DROP ANY DIRECTORY
The table creation works fine under 9.2.0.8 (our current required
version). However the application generates an ORA-00942 table or view does
not exist when run under 10g (10.2.0.1 and 10.2.0.3).
The following statement is the problem:
CREATE TABLE bulkload33 (
field1 VARCHAR2(2000),field2 VARCHAR2(2000),field3 VARCHAR2(2000))
ORGANIZATION EXTERNAL (
TYPE oracle_loader DEFAULT DIRECTORY EXT_100
ACCESS PARAMETERS ( RECORDS DELIMITED BY "\r\n"
CHARACTERSET 'WE8ISO8859P1'
BADFILE EXT_100:'bulkload_bad.csv'
LOGFILE EXT_100:'bulkload_log.csv'
FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"' MISSING FIELD VALUES ARE NULL REJECT ROWS WITH ALL NULL FIELDS (
field1 CHAR(2000),field2 CHAR(2000),field3 CHAR(2000),field4 CHAR(2000)))
LOCATION ('bulkload.csv')
) REJECT LIMIT UNLIMITED PARALLEL;
To clarify, the preceding statement, when handled by the process
for a queue message, failes with an ORA-00942.
Note that I can issue the command directly, as BLB or SYS, against
the BL schema with no problems. Further, as user BLB or SYS, I can do
the following:
CREATE OR REPLACE PROCEDURE dotest
IS
l_sql varchar2(2000);
BEGIN
l_sql := 'CREATE TABLE bulkload33 (
field1 VARCHAR2(2000),field2 VARCHAR2(2000),field3 VARCHAR2(2000))
ORGANIZATION EXTERNAL (
TYPE oracle_loader DEFAULT DIRECTORY EXT_100
ACCESS PARAMETERS ( RECORDS DELIMITED BY "\r\n"
CHARACTERSET ''WE8ISO8859P1''
BADFILE EXT_100:''bulkload_bad.csv''
LOGFILE EXT_100:''bulkload_log.csv''
FIELDS TERMINATED BY '',''
OPTIONALLY ENCLOSED BY ''"'' MISSING FIELD VALUES ARE NULL REJECT ROWS WITH ALL NULL FIELDS (
field1 CHAR(2000),field2 CHAR(2000),field3 CHAR(2000),field4 CHAR(2000)))
LOCATION (''bulkload.csv'')
) REJECT LIMIT UNLIMITED PARALLEL';
EXECUTE IMMEDIATE l_sql;
END;
show errors
EXEC dotest
Does anyone have any ideas of why this doesn't work under 10g? Metalink
has yielded no clues so far.
Thanks.Define "has full access to the BL schema" given that it is impossible to grant access rights, in Oracle, by schema. What was done and how was it done?
My guess is that the privs were granted in a role, rather than explicitly, as is required for PL/SQL.
Maybe you are looking for
-
We're using wa-a-ay too much disk space for a growing photo collection. My daughter is a camera freak with four kids -- need I say more? In my current test folder the sizes of the original photos range from 2.3 MB to 4.2 MB. I picked one photo at
-
SSD Install Question. Does it need to be formatted?
I guess what I am trying to say is, do I have to format the new SSD before I install it or can I simply remove the old HD and install the new SSD, turn on the MBP and Command+ R when the gray screen comes on and restore from the last TimeMachine back
-
SO_OCJECT_SEND Time Zone Problem
Hello everybody, our SAP systems time zone is CET and our MS Exchange servers timezone is EET. So when we send emails from SAP to MS Exchange server(outlook), the mail time seems incorrect in the mail. For example when we send an email at 13:00 PM fr
-
Why has dr.web light ben removed from the app store
Why has dr.web light ben removed from the app store and from my shopping list?
-
How to download songs and movies from iTunes? e top bar...
How to download songs and movies from iTunes? The music and movie tab is not on the top bar at the iTunes store...