Solved

How to set default value in Oracle SQL*Loader for a date field?

Posted on 2015-02-14
2
404 Views
Last Modified: 2015-02-14
Dear Experts,

I'm importing CSV files using SQL*Loader. One of the fields in the files is in "date" type. Sometimes that field's value comes greater than the sysdate by mistake, causing ora-14400 errors since corresponding date's partition does not exist in the related database table. How can I set this fields's value in control file to sysdate as default in such a condition?

Best Regards.
0
Comment
Question by:GurcanK
2 Comments
 
LVL 13

Accepted Solution

by:
Alexander Eßer [Alex140181] earned 100 total points
ID: 40610154
You should be able to use DECODE and/or CASE..WHEN statements within your control file ;-)
0
 
LVL 76

Assisted Solution

by:slightwv (䄆 Netminder)
slightwv (䄆 Netminder) earned 400 total points
ID: 40610266
The above post is correct.  CASE will work.

Here is a test control file:
LOAD DATA
INFILE *
TRUNCATE INTO TABLE Tab1
FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
(
col1 char(10) "case when to_date(:col1,'mm/dd/yyyy') > sysdate then sysdate else to_date(:col1,'mm/dd/yyyy') end"
)
begindata
01/01/2014
01/01/2016

Open in new window


Test table:
create table tab1(col1 date);

Open in new window

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

Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
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…
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.

757 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

22 Experts available now in Live!

Get 1:1 Help Now