Solved

Sql Loader

Posted on 2007-12-05
4
601 Views
Last Modified: 2013-12-18
We have 10 column in the datafile and 3 column  in our staging table. We need to pick the 7th column out of the data file and append into the 2nd column of the staging table using sql loader.  This is what we have for syntax so far.

LOAD DATA
INFILE 'C:\DATA.txt'
BADFILE 'C:\DATA.bad'
DISCARDFILE 'C:\DATA.dsc'
APPEND INTO TABLE "STAGING_TABLE"
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
  (COLUMN_1,  COLUMN_2,   COLUMN_3)
 
This syntax seems to insert the first 3 columns from the datafile to the 3 columns in the staging tables, it won't allow us to pick the 7th column for the datafile to insert into the 2nd column in the staging table.  This does not seem to work. Any help would be great
0
Comment
Question by:rrisal
  • 2
4 Comments
 
LVL 9

Accepted Solution

by:
joebednarz earned 500 total points
ID: 20415271
I would avoid using Sql Loader.  Try, instead, using externally organized tables:

SQL> create table MY_EXTERNAL_TABLE
  2      ( empl_id varchar2(3),
  3        last_name varchar2(50),
  4        first_name varchar2(50),
  5        ssn varchar2(9),
  6       email_addr varchar2(100),
  7        years_of_service number(2,0)
  8      )
  9      organization external
 10      ( default directory ORACLE_DIRECTORY_OBJECT
 11        access parameters
 12        ( records delimited by newline
 13          fields terminated by ','
 14        )
 15        location ('my_data_file.csv')  
 16    );

From there, you simply can do an INSERT accessing the "external" data in an SQL query.
0
 
LVL 9

Expert Comment

by:joebednarz
ID: 20415290
In case you need it:

CREATE OR REPLACE DIRECTORY oracle_directory_object
AS 'C:\my_directory';

GRANT READ ON DIRECTORY oracle_directory_object TO user_name;

Then make sure your data file is in the directory specified...
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question