If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Oracle > How to handle wrong dates in sql loader.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-05-12, 01:49
pavani.vnc pavani.vnc is offline
Registered User
 
Join Date: Jan 2012
Posts: 3
How to handle wrong dates in sql loader.

I am working on Sql*loader.In my csv file or flat file,i have date records and few records having date like 31-feb-2010.now am loading data into my table, at that time am getting error due to that wrong date(31-feb-2010).because of this no record was inserted into my table.
here what i want is
1.if am getting this error also ,i want to get inserted all remaining records into my table except that error record.
2.if am getting wrong dates in Csv file .how to handle that error while writing control file.
Please give solution for this.

Thanks in advance.
Pavani
Reply With Quote
  #2 (permalink)  
Old 01-05-12, 11:21
LKBrwn_DBA LKBrwn_DBA is offline
Registered User
 
Join Date: Jun 2003
Location: West Palm Beach, FL
Posts: 2,456
Cool

Quote:
Originally Posted by pavani.vnc View Post
1.if am getting this error also ,i want to get inserted all remaining records into my table except that error record.
In controlfile, first line: OPTIONS (ERRORS=0)
Quote:
2.if am getting wrong dates in Csv file .how to handle that error while writing control file.
Please give solution for this.
Once all records are loaded, fix the data in the "bad" file and load that file.
-- Or --
Create external table (bypass sql*loader) and validate + load the data using sql.
__________________
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
Reply With Quote
  #3 (permalink)  
Old 01-05-12, 13:38
Littlefoot Littlefoot is offline
Lost Boy
 
Join Date: Jan 2004
Location: Croatia, Europe
Posts: 3,629
Or, write a function that'll accept "date" values from the CSV file, decide whether it is valid or not (and fix it if that's the case) and return a valid value. You'd use that function in SQL*Loader control file, such as
Code:
...
date_column date "my_date_fix_function (:date_column)",
...
Reply With Quote
  #4 (permalink)  
Old 01-06-12, 03:05
pavani.vnc pavani.vnc is offline
Registered User
 
Join Date: Jan 2012
Posts: 3
hi

Once all records are loaded, fix the data in the "bad" file and load that file.
---thank you so much.
now its working now.
-- Or --
Create external table (bypass sql*loader) and validate + load the data using
sql.
--can explain in detail because how to bypass sql*loader.

Thanks in advance.
Pavani.
Reply With Quote
  #5 (permalink)  
Old 01-06-12, 03:07
pavani.vnc pavani.vnc is offline
Registered User
 
Join Date: Jan 2012
Posts: 3
write a function that'll accept "date" values from the CSV file, decide whether it is valid or not (and fix it if that's the case) and return a valid value. You'd use that function in SQL*Loader control file,
such as ...date_column date "my_date_fix_function (:date_column)",
--------
Okay but how function will take date values from CSV file.

thanks
Pavani.
Reply With Quote
  #6 (permalink)  
Old 01-06-12, 10:02
LKBrwn_DBA LKBrwn_DBA is offline
Registered User
 
Join Date: Jun 2003
Location: West Palm Beach, FL
Posts: 2,456
Cool

Quote:
Originally Posted by pavani.vnc View Post
--can explain in detail because how to bypass sql*loader.
.
When you create external table, you can query the csv data as regular table using sql commands.

Check out the "Organization External" clause in the fine OracleŽ Database SQL Language Reference.
__________________
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

Last edited by LKBrwn_DBA; 01-06-12 at 10:07.
Reply With Quote
  #7 (permalink)  
Old 01-06-12, 10:14
Littlefoot Littlefoot is offline
Lost Boy
 
Join Date: Jan 2004
Location: Croatia, Europe
Posts: 3,629
Quote:
Originally Posted by pavani.vnc View Post
Okay but how function will take date values from CSV file.
As I told you in my previous message; didn't you see that piece of code?
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On