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

x
?
Solved

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

Posted on 2015-02-14
2
Medium Priority
?
903 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 14

Accepted Solution

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

Assisted Solution

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
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 Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.
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.
Suggested Courses

885 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