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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Loader-NULLIF or WHEN ?

Status
Not open for further replies.

drkestrel

MIS
Sep 25, 2000
439
GB
I have a SQL Loader control file as follows

Code:
--Load XE Initialisation data from datascope into instrument table
--Test NULLIF Clause in SQL Loader

Options (userid=test)


Load Data
infile 'test.dat'

REPLACE
-- load data wheather the table contain data or empty

Into table Test

(
CODE			POSITION(01:05)		CHAR WHEN(CODE NOT LIKE '% %')
)

I get error Expecting valid column specification, "," or ")", found keyword when.
CODE POSITION(01:05) CHAR WHEN(CODE NOT LIKE '% %')


However,
Code:
CODE			POSITION(01:05)		CHAR NULLIF (CODE='   ')
works.

What i need the SQL Loader to do is to only import a record IFF code contains no spaces. Possible or not?

Neither WHEN nor NULLIF seems to like the tag
Code:
 LIKE '% %'
!
 
I think you have to move the when clause so that it's outside the parentheses that delimit the column list. Try the following

.
.
.
Into table Test
WHEN(CODE NOT LIKE '% %')
(
CODE POSITION(01:05) CHAR
)
 
I tried
Code:
........
Into table
WHEN (CODE<>-1) 
(
CODE    POSITION(01:05) CHAR
)

I received error Expecting quoted string or hex identifier, found &quot;-&quot;..

The field code is defined as NUMBER(3).


 
Clearly the problem is that CODE is CHAR rather than numeric, so when you say &quot;CODE<>-1&quot; you get an error. Oracle expects a quoted string like CODE <> '-1' instead of a number.

I think the solution at this point is up to you. I don't know the format of your data, so I can't guess what values should be selected for loading. You might be able to try something like

TO_NUMBER(CODE) <> -1

but this would probably generate an error if your data contains alpha characters.
 
Actually on reconsideration your problem may have a simple solution. If your database column is already defined as numeric, then you are probably just using the wrong format for your input file. Try something like

CODE POSITION(01:05) INTEGER EXTERNAL
or
CODE POSITION(01:05) DECIMAL EXTERNAL

depending on how the input file is formatted.

 
For your second resolution, if position 01:05 contains one ore more spaces?
 
For your second resolution, if position 01:05 contains one ore more spaces (now that I have changed CODE to be of type NUMBER)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top