Following is the content of a flat text file created in Notepad. I named the file 'c:\dhunt\sqldba\ALM\Input\Cimteet.txt').
The file simulates flat files that you indicated that you want to process in Oracle.
Code:
This is random, flat-file text, on multiple lines,
in a file named 'c:\dhunt\sqldba\ALM\Input\Cimteet.txt').
I can cause Oracle to treat this flat file as a TABLE,
without any implication on the Oracle instance.
I can write logic to parse the lines and process them any
way I want.
I can also create the records in this flat file as having
columns that are fixed-length or delimited by commas,
tabs, or any other special character that I choose.
This posting shows that not only can you process one or more
flat files without having the "utl_file_dir" parameter set,
but you can also process the flat file(s) as one or more
Oracle tables!
This means that you can avoid using all of the syntactical
intricacies of Oracle's "utl_file" infrastructure and even
process flat files as Oracle tables, without even using PL/SQL.
The following code shows:
1) That my instance's "utl_file_dir" parameter is undefined,
2) How to specify an o/s path as a location for a flat file to process.
(This command requires DBA privileges, but you do not need to
bounce the database or change any init.ora parameters.)
3) How to create a flat-file "external" table
4) How to access the flat-file, external table as a normal Oracle table.
Code:
col p heading "Parameter" format a15
col v heading "Value" format a15
select name p, value v from v$parameter
where name like 'utl%';
Parameter Value
--------------- ---------------
utl_file_dir <-- Notice there is no valid value for a directory
create or replace directory ALMInput as 'c:\dhunt\sqldba\ALM\Input'
/
Directory created.
create table cimteet (txt varchar2(1000))
organization external
( type oracle_loader
default directory ALMInput
access parameters
(records delimited by newline
fields terminated by '^'
)
location ('Cimteet.txt')
)
reject limit unlimited;
Table created.
desc cimteet
Name Null? Type
----------------------- -------- --------------
TXT VARCHAR2(1000)
select * from cimteet;
TXT
---------------------------------------------------------
This is random, flat-file text, on multiple lines,
in a file named 'c:\dhunt\sqldba\ALM\Input\Cimteet.txt').
I can cause Oracle to treat this flat file as a TABLE,
without any implication on the Oracle instance.
I can write logic to parse the lines and process them any
way I want.
I can also create the records in this flat file as having
columns that are fixed-length or delimited by commas,
tabs, or any other special character that I choose.
11 rows selected.
Your DBA should be delighted to co-operate with the
"CREATE DIRECTORY..." command since it resolves your need without any negative implications on your, or any other, Oracle instance. (Pretty cool, huh!)
Let us know if this satisfactorily overcomes your challenge.
![[santa] [santa] [santa]](/data/assets/smilies/santa.gif)
Mufasa
(aka Dave of Sandy, Utah, USA)
[I provide low-cost, remote Database Administration services:
www.dasages.com]