Oracle: SQL Loader Example: Evaluate a value with case when
The following example evaluates the first value in the CSV file to be loaded with a cascade of case when then to translate an (numeric) id into a character string.
create table tq84_sql_loader_case_when (
type_ varchar2(3),
num integer
);
load data
infile 'load.dat' -- "str '\r\n'"
truncate into table tq84_sql_loader_case_when
fields terminated by ';' (
type_ "case :type_
when '1' then 'foo'
when '2' then 'bar'
when '3' then 'baz'
else '???'
end",
num char
)