Solved

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

Posted on 2015-02-14
2
518 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.

Question has a verified solution.

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

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…
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
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.
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.

856 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