Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Sql Loader Scripts in Oracle

Posted on 2011-03-10
12
Medium Priority
?
676 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 6
12 Comments
 
LVL 77

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 77

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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 77

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 77

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 77

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 77

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
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 explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

719 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