Reputation: 1138
I'm trying to use SQL Loader and while inserting the data into the tables I need to check some conditions and insert the data.
Example:
CASE COLUMNA
WHEN 'NULL'
-- INSERT NULL VALUE IN IT INSTEAD OF STRING 'NULL'
ELSE
-- INSERT THE DATA AS IS
END
Can we use these case statements in the SQL Loader control file? Couldn't find good examples for this any where.
Upvotes: 1
Views: 759
Reputation: 10360
An FYI that for more complex tests or other needs that you can reuse you can also call functions or package members that return a value:
...
START_DATE "UTILITY_PKG.VALIDATE_DATE(:START_DATE)"
Or queries (have to enclose in perentheses):
START_DATE "(select sysdate from dual)",
Upvotes: 0
Reputation: 9886
Try adding the codition in your control file like:
load data
APPEND INTO TABLE XXX
fields terminated by "\t"
TRAILING NULLCOLS
( --Condition which you can add.
START_DATE "CASE WHEN length(:START_DATE ) < 10 THEN null ELSE :START_DATE END"
)
where START_DATE
isthe column of the table
Upvotes: 1