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.

Koushik Ravulapelli
  • 1,140
  • 11
  • 30

2 Answers2

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

Koushik Ravulapelli
  • 1,140
  • 11
  • 30
XING
  • 9,608
  • 4
  • 22
  • 38
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)", 
Gary_W
  • 9,933
  • 1
  • 22
  • 40