Problem
You have a file which is accessible to the DB tier, but you don't want to write a SQL*Loader.Solution
Create an external table. The principles and syntax are very similar to SQL*Loader.Here is an example
drop table ext_tab;
CREATE TABLE ext_tab (
invoice_id varchar2(100), DISTRIBUTION_LINE_NUMBER varchar2(100), TYPE_1099 varchar2(100))
ORGANIZATION EXTERNAL (
TYPE oracle_loader
DEFAULT DIRECTORY APPLPTMP
ACCESS PARAMETERS (
RECORDS DELIMITED BY NEWLINE
BADFILE 'bad_%a_%p.bad'
LOGFILE 'log_%a_%p.log'
FIELDS TERMINATED BY X'9' OPTIONALLY ENCLOSED BY '"'
MISSING FIELD VALUES ARE NULL
REJECT ROWS WITH ALL NULL FIELDS
(invoice_id, DISTRIBUTION_LINE_NUMBER, TYPE_1099))
LOCATION ('Test.txt')
)
PARALLEL
REJECT LIMIT UNLIMITED
NOMONITORING;
select *
from ext_tab;
Result
Acknowledgment
Plenty more examples here:
http://psoug.org/reference/externaltab.html
Comments
Post a Comment