Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Sql Loader Scripts in Oracle

Posted on 2011-03-10
12
Medium Priority
?
677 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 78

Accepted Solution

by:
slightwv (䄆 Netminder) earned 2000 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 78

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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 78

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 78

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
 

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 78

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 78

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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

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…
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
Suggested Courses

916 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