1

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.

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

Comments

0

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)", 

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.