Solved

Sql Loader Scripts in Oracle

Posted on 2011-03-10
12
667 Views
Last Modified: 2012-05-11
Hi,
 Below is one of the  sql loader script which is being used to  load data into oracle tables. But while the data is being loaded it creating spaces in the rows. How to avoid this space

LOAD DATA
INFILE    '/usr/summary/DBload.txt'
BADFILE   '/usr/Scripts/error_book.bad'
DISCARDFILE '/usr/Scripts/error_book.dsc'
APPEND
INTO TABLE INFO_STAGE
FIELDS TERMINATED BY "|"
TRAILING NULLCOLS
(
    ID,
    TITLE,
    TOTA_FILES,
    STATUS char "nvl(:STATUS,'N')"

)
0
Comment
Question by:new_perl_user
  • 6
  • 6
12 Comments
 
LVL 76

Accepted Solution

by:
slightwv (䄆 Netminder) earned 500 total points
ID: 35098617
try:

LOAD DATA
INFILE    '/usr/summary/DBload.txt'
BADFILE   '/usr/Scripts/error_book.bad'
DISCARDFILE '/usr/Scripts/error_book.dsc'
APPEND
INTO TABLE INFO_STAGE
FIELDS TERMINATED BY "|"
TRAILING NULLCOLS
(
    ID "trim(:id),
    TITLE "trim(:title)",
    TOTA_FILES,
    STATUS char "nvl(:STATUS,'N')"

)
0
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
ID: 35098623
I guess I should ask:  The columns in the table are varchar2 and not char correct?
0
 

Author Comment

by:new_perl_user
ID: 35098640
yes the columns are varchar
0
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
ID: 35098721
See if the trims work for you.  TOTA_FILES sounded like a number so I didn't add it there.
0
 

Author Comment

by:new_perl_user
ID: 35098926
I tried Trim but it did not work. I mean still it is generating some space while loading.
0
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
ID: 35098938
Can you post the table definition and some sample data from '/usr/summary/DBload.txt'?

I'll see if I can recreate this on my database.
0
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.

 

Author Comment

by:new_perl_user
ID: 35099070
Table:
ID               VARCHAR2(25 byte)
TITLE          VARCHARE2(256 byte)
TOTAL_FILES   NUMBER
STATUS            CHAR

Attached is the sample file I am trying to load.  
DBload.txt
0
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
ID: 35099153
It seems fine to me.  My test was done with Oracle 10.2.0.3 on Windows.

drop table tab1 purge;
create table tab1(
ID            VARCHAR2(25 byte),
TITLE         VARCHAR2(256 byte),
TOTAL_FILES   NUMBER,
STATUS        CHAR(1)
);


-- load the data with:  sqlldr user/password control=q.ctl

--check for spaces
select
':' || ID           || ':',
':' || TITLE        || ':',
':' || TOTAL_FILES  || ':',
':' || STATUS       || ':'
from tab1;



:5542335P:
:An enquiry into the nature, cause and cure, of the angina suffocativa,/:
:44:                                       :N:


1 row selected.

LOAD DATA
INFILE    *
APPEND
INTO TABLE tab1
FIELDS TERMINATED BY "|"
TRAILING NULLCOLS
(
    ID,
    TITLE,
    TOTAL_FILES,
    STATUS char "nvl(:STATUS,'N')"

)
begindata
5542335P|An enquiry into the nature, cause and cure, of the angina suffocativa,/|44|

Open in new window

0
 

Author Comment

by:new_perl_user
ID: 35099550
It is working now with  the trim option, Thank You.  One more thing  I have another loader Script which is creating am empty row after the load is done. How to  overcome that empty row.
0
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
ID: 35099575
>>One more thing  I have another loader Script which is creating am empty row after the load is done. How to  overcome that empty row.

Is there a blank line in the data file that might be getting loaded?

You should probably open a new question and provide the details or that control file.  Be sure to provide sample data that reproduces the problem you describe.

If we can reproduce what you describe, it's a lot easier to provide a solution.

0
 

Author Comment

by:new_perl_user
ID: 35099607
Sure. I will close this and open a new one and post the details.
0
 

Author Comment

by:new_perl_user
ID: 35099757
Hi,
A new question was opened for the above problem with title "sql loader empty row". If possible can you look into it. I am closing this.

Thanks,
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

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…
Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

744 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

15 Experts available now in Live!

Get 1:1 Help Now