Solved

Sql Loader

Posted on 2007-12-05
4
599 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.

Join & Write a Comment

Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now