Press "Enter" to skip to content

SQL Loader Control File WHEN Clause Example

In SQL Loader Control File, you can use WHEN clause to tell SQL Loader to load the data only when the condition is true. Also, you can use the WHEN clause to load data into multiple tables. Below is an example.

SQL Loader Control File WHEN Clause Example

LOAD DATA
APPEND
INTO TABLE JOB_HISTORY_10
when DEPARTMENT_ID = '10'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
(
EMPLOYEE_ID,
START_DATE,
END_DATE,
JOB_ID, 
DEPARTMENT_ID
)
INTO TABLE JOB_HISTORY_20
when DEPARTMENT_ID = '20'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
(
EMPLOYEE_ID,
START_DATE,
END_DATE,
JOB_ID, 
DEPARTMENT_ID
)

See also: