Using SQL*Loader, I want a condition like this:
Load the record if : substr(Col,3,2)='06'
Col ------ 10062034 . . .
Is there any way to combine WHEN with substr (or any other function) in control file?
I tried WHEN (substr(Col,3,2)='06') but it didn’t work.
No, the syntax for the
WHENclause is quite restrictive; see http://docs.oracle.com/cd/B14117_01/server.101/b10825/ldr_control_file.htm#i1005657. You can only restrict based on either an entire field, or else on specific character positions. That said, if you’re using a fixed format, then you can expresssubstr(Col,3,2)as a range of character positions, and that will work. For example, ifColstarts at character #20, then you can useWHEN (22:23) = '06'. But if you’re using a free format, likeFIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY '"', then you won’t generally know the character-offset ofCol.