SQL Loader WHEN clause with NULL Values [message #638854] |
Tue, 23 June 2015 09:23 |
|
agarwalnidhi3008
Messages: 3 Registered: June 2015 Location: India
|
Junior Member |
|
|
Hi All,
I am facing issue with loading data through sql loader.
I have a column for which we receive mutliple values as well as NULL
for exmple col1 values NULL,0000,00001,00002,00003
My control file looks like
LOAD DATA
INTo TABLE abc
APPEND
WHEN col1 <> 0003
FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
(
col2
col1 "NVL(:col1,'0000')"
)
in my data file for col1 ,all values are NULL.. then above condition does not work.
Please let me know how can I handle NULL case in WHEN Clause.
I tried WHEN COl1= BLANKS--it is also not working.
Thanks in advance.
|
|
|
|
|
Re: SQL Loader WHEN clause with NULL Values [message #638862 is a reply to message #638856] |
Tue, 23 June 2015 13:47 |
|
Littlefoot
Messages: 21823 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
I spent some time trying to solve the problem using SQL*Loader only, but I failed.
Normally, I'd put it aswhen col1 <> '0003' and col1 = '' but it causes all records to be discarded as WHEN clauses failed. It seems that WHEN clause can't check whether a column equals NULL or '' (two single quotes) or BLANKS. On the other hand, you can use(which causes 0000 and 0003 records to be loaded, but that's not what we are looking for).
I tried different options (such as PRESERVE BLANKS) but none of them helped.
Therefore, my suggestion is to- load all records into a staging table and - using SQL (INSERT INTO) insert only required records into the target table, or
- use external tables feature which, basically, skips the first part of the previous suggestion and enables you to directly INSERT records you want
Finally, I hope Barbara (Boehmer) will see this question and provide a solution. I'm really interested in seeing it.
|
|
|
|
|
|
Re: SQL Loader WHEN clause with NULL Values [message #638874 is a reply to message #638868] |
Wed, 24 June 2015 00:56 |
|
Michel Cadot
Messages: 68733 Registered: March 2007 Location: Saint-Maur, France, https...
|
Senior Member Account Moderator |
|
|
agarwalnidhi3008 wrote on Wed, 24 June 2015 06:35Hi All...Great thanks for all suggested solutions..I think I need to go with staging table suggestion only..
Investigate external table, you then don't need to store the data you don't want and it is as fast as SQL*Loader if you could do it.
The drawback is that the file must reside on or be accessible (through NFS like way) from the database server.
|
|
|