Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Loader Control file question 1

Status
Not open for further replies.

AlStl

MIS
Oct 2, 2006
83
US
Hi there, Little help needed. I am dealing with a pipe delimited file ex:

Transaction|Place|RDATE|Type
Manual|Chicago|1986-07-14 00:00:00.000|Failed
Manual|NULL|NULL|Failed

My control file look like this:

Fields terminated by '|' optionally enclosed by '"'

{

Transaction,
Place NULLIF :)Place='NULL'),
RDATE "To_DATE :)RDATE, 'YYYY-MM-DD HH24:MI:SS') NULLIF :)RDATE='NULL')",
TYPE
)

For some reason SQL loader is not liking this line:

RDATE "To_DATE :)RDATE, 'YYYY-MM-DD HH24:MI:SS') NULLIF :)RDATE='NULL')"

I am getting error:
Record 1: Rejected - Error on table XXX, column RDATE

How can I handle date conversion (mind this data file is from SQL server) and possible string 'NULL' values for same data element i.e. RDATE. In other words I can receive string 'NULL' or DATE as shown above in RDATE field.

Thx

Al
 
You have to apply a single SQL function to the column, whereas you are attempting to apply two. You will have to combine it together using either a DECODE or CASE e.g.

DECODE:)RDATE, 'NULL', to_date(null), TO_DATE:)RDATE, 'YYYY-MM-DD HH24:MI:SS'))

For Oracle-related work, contact me through Linked-In.
 
Dagon,

Worked like a charm. I really appreciate it.

Al
 
Al,

Be sure to award a
star.gif
to Dagon for his helpful post.

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
“People may forget what you say, but they will never forget how you made them feel.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top