You can use the decode function:
decode(:FLOATVALUE, '{}', NULL, :FLOATVALUE)
That says: if FLOATVALUE is '{}', insert NULL, otherwise insert FLOATVALUE
Question
I have a field called "FLOATVALUE" in csv/text file. I receive this file from third party, this has below possible values
- NULL
- {}
- Any number
When I insert this value as below
.... [OTHER FIELD CHECKS]
isValid "nvl(:isValid, '')",
FLOATVALUE FLOAT EXTERNAL "nvl(:FLOATVALUE, NULL)"
.... [OTHER FIELD CHECKS]
Its checking whethre ":FLOATVALUES" is null or not. If yes it's inserting NULL into the oracle table, if not it's failing to insert for the values ("{}").
The field I'm loading into oracle table is 'FLOATVALUE FLOAT'. I would like to have something like below in my control file -
- if :FLOATVALUE is null insert NULL
elseif :FLOATVALUE is '{}' insert NULL
else inert original value
How can specify a condition like above in control file?
Solution
You can use the decode function:
decode(:FLOATVALUE, '{}', NULL, :FLOATVALUE)
That says: if FLOATVALUE is '{}', insert NULL, otherwise insert FLOATVALUE
OTHER TIPS
You can use either decode or case when statement. See the example below
Decode :
decode(Float_value,{},NULL,Float_value);
Case when :
CASE [ FLOAT_VALUE ]
WHEN NULL THEN NULL
WHEN {} THEN NULL
ELSE [FLOAT_VALUE]
END;