Solved

SQL Loader control file format to load data file with changing  number of column : NEW QUESTION

Posted on 2008-10-13
2
2,774 Views
Last Modified: 2013-12-19
I had asked this question before and had received a good response which helped me. But again I am stuck in between. I am attaching my sql loader control file and my sample data files data.

Question is that in the control file I have around a few optional columns at the end, starting from the column TA_NUMBER. These columns may be there or may not be there in the file. I am stuck at the field delimiter that I can give to each of this optionaly column. Because the field delimiter also becomes the row delimter for that column if all other columns are not there in the data file. How should I tackle this?

In the attached file, the first section is the control file structure, the second sections is the data file single record having columns till the column TA_NUMBER. This is sucessfully loaded. The third section is the same data file with one additional column MGR_CODE. But this data fails to load since it is looking for "^M" delimiter for the TA_NUMBER coolumn. CTRL + M is the row delimiter in the data file.

THANKS YOU FOR YOUR TIME AND HELP.

$wapnil
sqlloader.txt
0
Comment
Question by:spattewar
2 Comments
 
LVL 29

Accepted Solution

by:
MikeOM_DBA earned 500 total points
ID: 22706879

First you need to get rid of the ^Ms:

dos2unix infile.txt infile.txt

Then use this controlfile:

LOAD DATA
REPLACE
INTO TABLE TEMP_EPAM_SECURITY_TXNS
WHEN (01) <> ',' AND (1:2) <> '""'
FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
(
PORTFOLIO,
SECURITY_ID,
TRAN_DESC,
TRAN_TYPE,
TRADE_DATE Date 'yyyy-mm-dd',
SETTLEMENT_DATE Date 'yyyy-mm-dd',
LOCAL_CURR,
FUNC_CURR,
QUANTITY,
TRADE_PRICE,
FUNC_SEC_FEES,
LOCAL_SEC_FEES,
FUNC_COMMISSION,
LOCAL_COMMISSION,
FUNC_PRINCIPAL,
LOCAL_PRINCIPAL,
FUNC_NET_PROCEEDS,
LOCAL_NET_PROCEEDS,
FUNC_ORIG_FACE_VALUE,
LOCAL_ORIG_FACE_VALUE,
FX_RATE,
LOT_NUMBER,
TA_NUMBER,
MGR_CODE,
FUNC_INTEREST,
LOCAL_INTEREST,
ISSUER_NAME
)

Open in new window

0
 
LVL 22

Author Closing Comment

by:spattewar
ID: 31505647
Works like a charm!
Exactly what I require. Thanks a lot!
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

Title # Comments Views Activity
Action link in Union Reports Not Working in OBIEE 11g 1 87
PAYER_ID has both atributes 4 39
Help on model clause 5 32
PL SQL Developer 7 35
Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.

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